functions.zsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 upgrade_oh_my_zsh() {
  29. /bin/sh $ZSH/tools/upgrade.sh
  30. }
  31. function tab() {
  32. osascript 2>/dev/null <<EOF
  33. tell application "System Events"
  34. tell process "Terminal" to keystroke "t" using command down
  35. end
  36. tell application "Terminal"
  37. activate
  38. do script with command "cd $PWD; $*" in window 1
  39. end tell
  40. EOF
  41. }
  42. function take() {
  43. mkdir -p $1
  44. cd $1
  45. }
  46. function tm() {
  47. cd $1
  48. mate $1
  49. }