functions.zsh 888 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function title {
  2. if [[ $TERM == "screen" ]]; then
  3. # Use these two for GNU Screen:
  4. print -nR $'\033k'$1$'\033'\\\
  5. print -nR $'\033]0;'$2$'\a'
  6. elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
  7. # Use this one instead for XTerms:
  8. print -nR $'\033]0;'$*$'\a'
  9. fi
  10. }
  11. function precmd {
  12. title zsh "$PWD"
  13. }
  14. function preexec {
  15. emulate -L zsh
  16. local -a cmd; cmd=(${(z)1})
  17. title $cmd[1]:t "$cmd[2,-1]"
  18. }
  19. function remote_console() {
  20. /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
  21. }
  22. function tab() {
  23. osascript 2>/dev/null <<EOF
  24. tell application "System Events"
  25. tell process "Terminal" to keystroke "t" using command down
  26. end
  27. tell application "Terminal"
  28. activate
  29. do script with command "cd $PWD; $*" in window 1
  30. end tell
  31. EOF
  32. }
  33. function take() {
  34. mkdir -p $1
  35. cd $1
  36. }
  37. function tm() {
  38. cd $1
  39. mate $1
  40. }