functions.zsh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 zsh_stats() {
  23. history | awk '{print $2}' | sort | uniq -c | sort -rn | head
  24. }
  25. function uninstall_oh_my_zsh() {
  26. /bin/sh $ZSH/tools/uninstall.sh
  27. }
  28. function tab() {
  29. osascript 2>/dev/null <<EOF
  30. tell application "System Events"
  31. tell process "Terminal" to keystroke "t" using command down
  32. end
  33. tell application "Terminal"
  34. activate
  35. do script with command "cd $PWD; $*" in window 1
  36. end tell
  37. EOF
  38. }
  39. function take() {
  40. mkdir -p $1
  41. cd $1
  42. }
  43. function tm() {
  44. cd $1
  45. mate $1
  46. }