functions.zsh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ## fixme, i duplicated this in xterms - oops
  2. function title {
  3. if [[ $TERM == "screen" ]]; then
  4. # Use these two for GNU Screen:
  5. print -nR $'\033k'$1$'\033'\\\
  6. print -nR $'\033]0;'$2$'\a'
  7. elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
  8. # Use this one instead for XTerms:
  9. print -nR $'\033]0;'$*$'\a'
  10. fi
  11. }
  12. function precmd {
  13. title zsh "$PWD"
  14. }
  15. function preexec {
  16. emulate -L zsh
  17. local -a cmd; cmd=(${(z)1})
  18. title $cmd[1]:t "$cmd[2,-1]"
  19. }
  20. function remote_console() {
  21. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  22. }
  23. function zsh_stats() {
  24. history | awk '{print $2}' | sort | uniq -c | sort -rn | head
  25. }
  26. function uninstall_oh_my_zsh() {
  27. /bin/sh $ZSH/tools/uninstall.sh
  28. }
  29. function upgrade_oh_my_zsh() {
  30. /bin/sh $ZSH/tools/upgrade.sh
  31. }
  32. function tab() {
  33. osascript 2>/dev/null <<EOF
  34. tell application "System Events"
  35. tell process "Terminal" to keystroke "t" using command down
  36. end
  37. tell application "Terminal"
  38. activate
  39. do script with command "cd \"$PWD\"; $*" in window 1
  40. end tell
  41. EOF
  42. }
  43. function take() {
  44. mkdir -p $1
  45. cd $1
  46. }
  47. function tm() {
  48. cd $1
  49. mate $1
  50. }
  51. # To use: add a .lighthouse file into your directory with the URL to the
  52. # individual project. For example:
  53. # https://rails.lighthouseapp.com/projects/8994
  54. # Example usage: http://screencast.com/t/ZDgwNDUwNT
  55. open_lighthouse_ticket () {
  56. if [ ! -f .lighthouse-url ]; then
  57. echo "There is no .lighthouse file in the current directory..."
  58. return 0;
  59. else
  60. lighthouse_url=$(cat .lighthouse-url);
  61. echo "Opening ticket #$1";
  62. `open $lighthouse_url/tickets/$1`;
  63. fi
  64. }
  65. alias lho='open_lighthouse_ticket'