functions.zsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. }