shosei

.zshrc

Mar 21st, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.09 KB | None | 0 0
  1.  
  2.  
  3. #########################################
  4. # .zshrc
  5. # The Z Shell config file
  6. #########################################
  7. # {{{ PATH #####################################################################
  8. # Add Google Android toolset
  9. # PATH=${PATH}:/home/cfd90/workspace/android_sdk_linux_m3-rc22a/tools
  10. # }}}
  11.  
  12. # {{{ History ##################################################################
  13. HISTFILE=~/.histfile
  14. HISTSIZE=1000
  15. SAVEHIST=1000
  16.  
  17. setopt appendhistory
  18. setopt sharehistory  # share history between multiple running terminals
  19. # }}}
  20.  
  21. # {{{ Key bindings #############################################################
  22. # REMINDER: C-V key  -  will print out key, for a nice reference
  23. bindkey -e                                   # vim sucks
  24.  
  25. # Useful piping shortcuts
  26. bindkey -s '^|l' "|less\n"                   # c-| l  pipe to less
  27. bindkey -s '^|g' '|grep ""^[OD'             # c-| g  pipe to grep
  28. bindkey -s '^|a' "|awk '{print $}'^[OD^[OD"  # c-| a  pipe to awk
  29. bindkey -s '^|s' '|sed -e "s///g"^[OD^[OD^[OD^[OD' # c-| s  pipe to sed
  30.  
  31. # Input controls
  32. bindkey '^[[1;3D' backward-word    # alt + LEFT
  33. bindkey '^[[1;3C' forward-word     # alt + RIGHT
  34. bindkey '_^?' backward-delete-word # alt + BACKSPACE  delete word backward
  35. bindkey '^[[3;3~' delete-word      # alt + DELETE  delete word forward
  36. bindkey '^[' self-insert           # alt + ENTER  allow multiline input
  37. bindkey '_t' transpose-words
  38. # }}}
  39.  
  40. # {{{ Completion ###############################################################
  41. ## Generated by compinstall
  42. zstyle :compinstall filename '/home/cfd90/.zshrc'
  43. autoload -Uz compinit
  44. compinit
  45. ## End Generated by compinstall
  46.  
  47. ## Taken from mako's .zshrc
  48. zstyle ':completion:*' menu select=1 _complete _ignored _approximate
  49. # allow one error for every three characters typed in approximate completer
  50. zstyle -e ':completion:*:approximate:*' max-errors \
  51.     'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
  52. # list of completers to use
  53. zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
  54. # seperate close errors from matches
  55. zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
  56. ## End taken from mako's .zshrc
  57. # }}}
  58.  
  59. ## {{{ Aliases #################################################################
  60. alias grep="egrep --color=auto"  # color grep output
  61. alias ls="ls --color"            # always show color
  62. alias l="ls -lh --color"         # laziness strikes again.
  63. alias la="ls -alh --color"       # list, show all, in a humane way
  64. alias ..="cd .."                 # save 3 keystrokes...
  65. alias cd..="cd .."               # for annoying typos...
  66. alias emacs="emacs -nw"          # always run emacs inside the console
  67. alias rm="rm -i"                 # can never be too careful...
  68. alias diff=colordiff             # pretty colors...
  69. alias p=pwd                      # more lazyness...
  70. alias c="clear;fortune rush"     # another quickie
  71. alias sr="screen -R"             # attach to screen session if running
  72. alias du="du -h"                 # humane treatment
  73. alias df="df -h"                 # humane treatment again
  74. alias untar="tar xzfv"           # yay, less random letters to know...
  75. alias ba="bzr add"               # Bazaar shortcuts...
  76. alias bi="bzr ignore"            # ...
  77. alias bm="bzr move"              # ...
  78. alias bd="bzr diff | colordiff"  # ...yay, I see colors...
  79. alias bk="bzr commit"            # stupid, useless calculator...
  80. alias bl="bzr log"               # ...
  81. alias bs="bzr status"            # ...
  82. alias bh="bzr help"              # *phew!* End of bazaar shorcuts
  83. alias apt-get="sudo apt-get"     # remove annoyingness
  84. alias su="su -s /bin/zsh"        # make it use zsh
  85. alias a="g '^alias' < ~/.zshrc"  # QUICKKEY - alias list
  86. alias d=dcop                     # QUICKKEY - dcop connections
  87. alias h="htop -u $(whoami) -t"   # QUICKKEY - system monitor
  88. alias j=jobs                     # QUICKKEY - show jobs
  89. alias k=kill                     # QUICKKEY - kill process
  90. alias e=$EDITOR                  # QUICKKEY - edit quickly
  91. alias m=more                     # QUICKKEY - yeah
  92. alias q=exit                     # QUICKKEY - like vim
  93. alias yank="dcop klipper klipper setClipboardContents"   # copy - kde (klipper)
  94. alias unyank="dcop klipper klipper getClipboardContents" # paste - kde (klipper)
  95. # }}}
  96.  
  97. # {{{ Functions ################################################################
  98. # yank 'a' file - kde only (klipper)
  99. function yankf() { yank "$(cat $1)" }
  100.  
  101. # visit bash quickly
  102. function bashorg() { lynx -dump "www.bash.org?$1" | less; }
  103.  
  104. # grabs latest .zshrc from dotfiles.org, and moves .zshrc to .zshrc.old
  105. # backs up .zshrc.old to .zshrc.old.old just in case ;)
  106. function updatezshrc() {
  107.         echo "Starting in 5 seconds... Ctrl+C to abort..."
  108.         sleep 5
  109.  
  110.         # back up .zshrc.old just in case, only if it exists
  111.         if [[ $(file .zshrc.old) != "" ]]; then
  112.                 mv .zshrc.old .zshrc.old.old
  113.         fi
  114.  
  115.         # Back up .zshrc
  116.         mv .zshrc .zshrc.old
  117.        
  118.         # Get new .zshrc from dotfiles.org
  119.         curl -o .zshrc http://dotfiles.org/~coder_/.zshrc
  120. }
  121. # }}}
  122.  
  123. # {{{ Pre-functions ############################################################
  124. # Set title of window
  125. function preexec() {
  126.   # When I print to the xterm title, \b doesn't seem to work, so this
  127.   # will hackily solve the problem of putting $FOOx$BAR, very ugly yes
  128.   # and there is probably a better way to do this in zsh, but I'm new to it
  129.   # also, why am I writing a comment like this to myself?
  130.   export size="$(echo \"$COLUMNS@x$LINES\" | sed s/@//g | sed s/\"//g)"
  131.  
  132.   # Show screen window, or running command
  133.   if [[ "$WINDOW" == "" ]]; then
  134.     if [[ $1 != "" ]]; then
  135.       # show running command, because it doesn't stick like screen
  136.       print -Pn "\e]0;$1 - $size\a"
  137.     else
  138.       print -Pn "\e]0;zsh - $size\a"
  139.     fi
  140.   fi
  141. }
  142.  
  143. # Show the directory in terminal title
  144. case $TERM in
  145.   xterm*)
  146.         precmd() { preexec }
  147.     ;;
  148. esac
  149. # }}}
  150.  
  151. # {{{ Variables ################################################################
  152. export BZR_EMAIL="Colin Drake "
  153. export BROWSER=/opt/firefox/firefox   # blah, duh.... etc.
  154. export VISUAL='emacs'                 # blah
  155. export EDITOR=$VISUAL                 # mi editero
  156. export BZR_EDITOR=$VISUAL             # bazaar editor
  157. export SVN_EDITOR=$VISUAL             # subversion editor
  158. export ZLS_COLORS=$LS_COLORS          # show ls colors.. grr..
  159. # }}}
  160.  
  161. # {{{ Prompt ###################################################################
  162. # Different prompts depending on if screen is running (checks $WINDOW)
  163. if [[ "$WINDOW" == "" ]]; then
  164.         export PS1='(%n@%m[%*]%# '           # prompt string
  165. else
  166.         export PS1="(%n($WINDOW)@%m[%*]%# "  # prompt string showing screen window
  167. fi
  168.  
  169. export RPROMPT=' %B%~%b%)'  # right side prompt string
  170. export PS2='%_>'            # basic secondary prompt
  171. # }}}
  172.  
  173. # {{{ Misc. Options ############################################################
  174. setopt autocd
  175. setopt cdablevars
  176. setopt correct  # correct commands
  177. # }}}
  178.  
  179. # {{{ Startup output ###########################################################
  180. fortune rush
  181. # }}}
Advertisement
Add Comment
Please, Sign In to add comment