Advertisement
Guest User

zshrc

a guest
Jul 19th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.03 KB | None | 0 0
  1. # Begining of the file
  2. # Main conf dir is /etc/zsh/zshrc
  3. # Written by Asmir; asmir [at] archlinux [dot] us
  4. ### Includes ###
  5. #{{{
  6. # Syntax highlight plugin
  7. source /usr/share/zsh/plugins/zsh-syntax-highlight/zsh-syntax-highlighting.zsh
  8. #}}}
  9.  
  10. ### Aliases ###
  11. #{{{
  12. alias pd='plowdown `xclip -o`'
  13. alias pacman='pacman-color'
  14. alias axel='axel -a'
  15. alias cmplayer='/usr/local/bin/mplayer-resume.py'
  16. alias ls='/usr/lib/cw/ls -b -CF --color=auto'
  17. alias w2l="iconv -f windows-1252 -t utf-8 $1 > $2"
  18. for c in cp rm chmod chown rename; do
  19.     alias $c="$c -v"
  20. done
  21. # Sufix aliases
  22. alias -s {conf,txt,rc,c,h}=vim
  23. alias -s {url,html}=dwb
  24. alias -s {mp3,mp4,avi,mkv,webm,ogg,rmvb,3gp}=mplayer
  25. alias -s {jpg,jpeg,png,tif,gif,svg}= feh
  26. alias -s tar.gz="tar -xvzf"
  27. alias -s tar.bz2="tar -xvjf"
  28. alias -s tar="tar -xvf"
  29. alias -s rar="unrar e"
  30. alias -s pdf=llpp
  31. #}}}
  32.  
  33. ### Functions ###
  34. #{{{
  35. ##Executes by every cd
  36. function chpwd() {
  37.     ls
  38.     echo -ne "\033]0;$PWD\007"
  39. }
  40.  
  41. ##Replace spaces with "_"
  42. function rs() {
  43. for file in *; do
  44.   mv $file ${file:gs/\ /_/}
  45. done
  46. }
  47.  
  48. is42(){
  49.     [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0
  50.     return 1
  51. }
  52. #}}}
  53.  
  54. ### Misc options ###
  55. #{{{
  56.  
  57. # Colorize stderr
  58. #exec 2>>(while read line; do
  59. #  print '\e[91m'${(q)line}'\e[0m' > /dev/tty; print -n $'\0'; done &)
  60.  
  61. eval `dircolors ~/.zsh/dircolors.256dark`
  62.  
  63. REPORTTIME=5                # report about cpu-/system-/user-time of command if running longer than 5 seconds
  64.  
  65. autoload -U compinit && compinit    # completion
  66. autoload -U colors && colors        # colors are good
  67. autoload -U zmv             # cool mv function
  68. setopt nobeep                       # i hate beeps
  69. setopt auto_cd                  # change dirs without cd
  70. setopt autopushd                    # automatically append dirs to the push/pop list
  71. setopt pushdignoredups              # and don't duplicate them
  72. setopt nocheckjobs                  # don't warn me about bg processes when exiting
  73. setopt nohup                        # and don't kill them, either
  74. setopt listpacked                   # compact completion lists
  75. setopt listtypes                    # show types in completion
  76. setopt extendedglob                 # weird & wacky pattern matching - yay zsh!
  77. setopt completeinword               # not just at the end
  78. setopt alwaystoend                  # when complete from middle, move cursor
  79. setopt nopromptcr                   # don't add \r which overwrites cmd output with no \n
  80. setopt printexitvalue               # alert me if something's failed
  81. setopt correct                  # spelling correction
  82. setopt inc_append_history       # append history to $HISTFILE
  83. setopt share_history            # share history betwen sessions
  84. setopt completealiases          # completion with aliases
  85. setopt histignorespace          # history ignores commands following whitespace
  86. setopt c_bases              # 0xFF
  87. setopt multios              # Allow Multiple pipes
  88. setopt notify               # Notify when jobs finish
  89. #setopt rm_star_wait            # wait 10s berfore answering to "rm /*"
  90. set -o emacs                # emacs keybind
  91. bindkey ' ' magic-space         # also do history expansion on space
  92. #}}}
  93.  
  94. ### Completion system ###
  95. #{{{
  96. # called later (via is4 && grmlcomp)
  97. # note: use 'zstyle' for getting current settings
  98. #         press ^xh (control-x h) for getting tags in context; ^x? (control-x ?) to run complete_debug with trace output
  99. grmlcomp() {
  100.     # TODO: This could use some additional information
  101.  
  102.     # allow one error for every three characters typed in approximate completer
  103.     zstyle ':completion:*:approximate:'    max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )'
  104.  
  105.     # don't complete backup files as executables
  106.     zstyle ':completion:*:complete:-command-::commands' ignored-patterns '(aptitude-*|*\~)'
  107.  
  108.     # start menu completion only if it could find no unambiguous initial string
  109.     zstyle ':completion:*:correct:*'       insert-unambiguous true
  110.     zstyle ':completion:*:corrections'     format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
  111.     zstyle ':completion:*:correct:*'       original true
  112.  
  113.     # activate color-completion
  114.     zstyle ':completion:*:default'         list-colors ${(s.:.)LS_COLORS}
  115.  
  116.     # format on completion
  117.     zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
  118.  
  119.     # automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
  120.     # zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
  121.  
  122.     # insert all expansions for expand completer
  123.     zstyle ':completion:*:expand:*'        tag-order all-expansions
  124.     zstyle ':completion:*:history-words'   list false
  125.  
  126.     # activate menu
  127.     zstyle ':completion:*:history-words'   menu yes
  128.  
  129.     # ignore duplicate entries
  130.     zstyle ':completion:*:history-words'   remove-all-dups yes
  131.     zstyle ':completion:*:history-words'   stop yes
  132.  
  133.     # match uppercase from lowercase
  134.     zstyle ':completion:*'                 matcher-list 'm:{a-z}={A-Z}'
  135.  
  136.     # separate matches into groups
  137.     zstyle ':completion:*:matches'         group 'yes'
  138.     zstyle ':completion:*'                 group-name ''
  139.  
  140.     if [[ "$NOMENU" -eq 0 ]] ; then
  141.         # if there are more than 5 options allow selecting from a menu
  142.         zstyle ':completion:*'               menu select=5
  143.     else
  144.         # don't use any menus at all
  145.         setopt no_auto_menu
  146.     fi
  147.  
  148.     zstyle ':completion:*:messages'        format '%d'
  149.     zstyle ':completion:*:options'         auto-description '%d'
  150.  
  151.     # describe options in full
  152.     zstyle ':completion:*:options'         description 'yes'
  153.  
  154.     # on processes completion complete all user processes
  155.     zstyle ':completion:*:processes'       command 'ps -au$USER'
  156.  
  157.     # offer indexes before parameters in subscripts
  158.     zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
  159.  
  160.     # provide verbose completion information
  161.     zstyle ':completion:*'                 verbose true
  162.  
  163.     # recent (as of Dec 2007) zsh versions are able to provide descriptions
  164.     # for commands (read: 1st word in the line) that it will list for the user
  165.     # to choose from. The following disables that, because it's not exactly fast.
  166.     zstyle ':completion:*:-command-:*:'    verbose false
  167.  
  168.     # set format for warnings
  169.     zstyle ':completion:*:warnings'        format $'%{\e[0;31m%}No matches for:%{\e[0m%} %d'
  170.  
  171.     # define files to ignore for zcompile
  172.     zstyle ':completion:*:*:zcompile:*'    ignored-patterns '(*~|*.zwc)'
  173.     zstyle ':completion:correct:'          prompt 'correct to: %e'
  174.  
  175.     # Ignore completion functions for commands you don't have:
  176.     zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*'
  177.  
  178.     # Provide more processes in completion of programs like killall:
  179.     zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
  180.  
  181.     # complete manual by their section
  182.     zstyle ':completion:*:manuals'    separate-sections true
  183.     zstyle ':completion:*:manuals.*'  insert-sections   true
  184.     zstyle ':completion:*:man:*'      menu yes select
  185.  
  186.     # provide .. as a completion
  187.     zstyle ':completion:*' special-dirs ..
  188.  
  189.     # run rehash on completion so new installed program are found automatically:
  190.     _force_rehash() {
  191.         (( CURRENT == 1 )) && rehash
  192.         return 1
  193.     }
  194.  
  195.     ## correction
  196.     # some people don't like the automatic correction - so run 'NOCOR=1 zsh' to deactivate it
  197.     if [[ "$NOCOR" -gt 0 ]] ; then
  198.         zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _files _ignored
  199.         setopt nocorrect
  200.     else
  201.         # try to be smart about when to use what completer...
  202.         setopt correct
  203.         zstyle -e ':completion:*' completer '
  204.            if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]] ; then
  205.                _last_try="$HISTNO$BUFFER$CURSOR"
  206.                reply=(_complete _match _ignored _prefix _files)
  207.            else
  208.                if [[ $words[1] == (rm|mv) ]] ; then
  209.                    reply=(_complete _files)
  210.                else
  211.                    reply=(_oldlist _expand _force_rehash _complete _ignored _correct _approximate _files)
  212.                fi
  213.            fi'
  214.     fi
  215.  
  216.     # command for process lists, the local web server details and host completion
  217.     zstyle ':completion:*:urls' local 'www' '/var/www/' 'public_html'
  218.  
  219.     # caching
  220.     [[ -d $ZSHDIR/cache ]] && zstyle ':completion:*' use-cache yes && \
  221.                             zstyle ':completion::complete:*' cache-path $ZSHDIR/cache/
  222.  
  223.     # TODO: so, why is this here?
  224.     #  zstyle '*' hosts $hosts
  225.  
  226.     # use generic completion system for programs not yet defined; (_gnu_generic works
  227.     # with commands that provide a --help option with "standard" gnu-like output.)
  228.     for compcom in cp deborphan df feh fetchipac head hnb ipacsum mv \
  229.                    pal stow tail uname ; do
  230.         [[ -z ${_comps[$compcom]} ]] && compdef _gnu_generic ${compcom}
  231.     done; unset compcom
  232.  
  233.     # see upgrade function in this file
  234.     compdef _hosts upgrade
  235. }
  236. grmlcomp
  237. #}}}
  238.  
  239. ### Prompt ###
  240. #{{{
  241. #prompt by hound
  242. PS1=$'%{\e[1;38m%}[%{\e[0m%} %{\e[1;35m%}%~%{\e[0m%}%{\e[1;38m%}]%{\e[0m%}%{\e[0;34m%}$%{\e[0m%} '
  243. #}}}
  244.  
  245. # vim:sw=4:ft=zsh:fdm=marker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement