functions.zsh 1.1 KB

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