[Home] Zsh logo

zshrc

Zsh Wizard

Download zshrc Return to Examples
  1. #
  2. # Example .zshrc file for zsh 4.0
  3. #
  4. # .zshrc is sourced in interactive shells. It
  5. # should contain commands to set up aliases, functions,
  6. # options, key bindings, etc.
  7. #
  8. # THIS FILE IS NOT INTENDED TO BE USED AS /etc/zshrc, NOR WITHOUT EDITING
  9. return 0 # Remove this line after editing this file as appropriate
  10. # Search path for the cd command
  11. cdpath=(.. ~ ~/src ~/zsh)
  12. # Use hard limits, except for a smaller stack and no core dumps
  13. unlimit
  14. limit stack 8192
  15. limit core 0
  16. limit -s
  17. umask 022
  18. # Set up aliases
  19. alias mv='nocorrect mv' # no spelling correction on mv
  20. alias cp='nocorrect cp' # no spelling correction on cp
  21. alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
  22. alias j=jobs
  23. alias pu=pushd
  24. alias po=popd
  25. alias d='dirs -v'
  26. alias h=history
  27. alias grep=egrep
  28. alias ll='ls -l'
  29. alias la='ls -a'
  30. # List only directories and symbolic
  31. # links that point to directories
  32. alias lsd='ls -ld *(-/DN)'
  33. # List only file beginning with "."
  34. alias lsa='ls -ld .*'
  35. # Shell functions
  36. setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility
  37. freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
  38. # Where to look for autoloaded function definitions
  39. fpath=($fpath ~/.zfunc)
  40. # Autoload all shell functions from all directories in $fpath (following
  41. # symlinks) that have the executable bit on (the executable bit is not
  42. # necessary, but gives you an easy way to stop the autoloading of a
  43. # particular shell function). $fpath should not be empty for this to work.
  44. for func in $^fpath/*(N-.x:t); autoload $func
  45. # automatically remove duplicates from these arrays
  46. typeset -U path cdpath fpath manpath
  47. # Global aliases -- These do not have to be
  48. # at the beginning of the command line.
  49. alias -g M='|more'
  50. alias -g H='|head'
  51. alias -g T='|tail'
  52. manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man)
  53. export MANPATH
  54. # Hosts to use for completion (see later zstyle)
  55. hosts=(`hostname` ftp.math.gatech.edu prep.ai.mit.edu wuarchive.wustl.edu)
  56. # Set prompts
  57. PROMPT='%m%# ' # default prompt
  58. RPROMPT=' %~' # prompt for right side of screen
  59. # Some environment variables
  60. export MAIL=/var/spool/mail/$USERNAME
  61. export LESS=-cex3M
  62. export HELPDIR=/usr/local/lib/zsh/help # directory for run-help function to find docs
  63. MAILCHECK=300
  64. HISTSIZE=200
  65. DIRSTACKSIZE=20
  66. # Watch for my friends
  67. #watch=( $(<~/.friends) ) # watch for people in .friends file
  68. watch=(notme) # watch for everybody but me
  69. LOGCHECK=300 # check every 5 min for login/logout activity
  70. WATCHFMT='%n %a %l from %m at %t.'
  71. # Set/unset shell options
  72. setopt notify globdots correct pushdtohome cdablevars autolist
  73. setopt correctall autocd recexact longlistjobs
  74. setopt autoresume histignoredups pushdsilent noclobber
  75. setopt autopushd pushdminus extendedglob rcquotes mailwarning
  76. unsetopt bgnice autoparamslash
  77. # Autoload zsh modules when they are referenced
  78. zmodload -a zsh/stat stat
  79. zmodload -a zsh/zpty zpty
  80. zmodload -a zsh/zprof zprof
  81. zmodload -ap zsh/mapfile mapfile
  82. # Some nice key bindings
  83. #bindkey '^X^Z' universal-argument ' ' magic-space
  84. #bindkey '^X^A' vi-find-prev-char-skip
  85. #bindkey '^Xa' _expand_alias
  86. #bindkey '^Z' accept-and-hold
  87. #bindkey -s '\M-/' \\\\
  88. #bindkey -s '\M-=' \|
  89. # bindkey -v # vi key bindings
  90. bindkey -e # emacs key bindings
  91. bindkey ' ' magic-space # also do history expansion on space
  92. bindkey '^I' complete-word # complete on tab, leave expansion to _expand
  93. # Setup new style completion system. To see examples of the old style (compctl
  94. # based) programmable completion, check Misc/compctl-examples in the zsh
  95. # distribution.
  96. autoload -U compinit
  97. compinit
  98. # Completion Styles
  99. # list of completers to use
  100. zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
  101. # allow one error for every three characters typed in approximate completer
  102. zstyle -e ':completion:*:approximate:*' max-errors \
  103. 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
  104. # insert all expansions for expand completer
  105. zstyle ':completion:*:expand:*' tag-order all-expansions
  106. # formatting and messages
  107. zstyle ':completion:*' verbose yes
  108. zstyle ':completion:*:descriptions' format '%B%d%b'
  109. zstyle ':completion:*:messages' format '%d'
  110. zstyle ':completion:*:warnings' format 'No matches for: %d'
  111. zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
  112. zstyle ':completion:*' group-name ''
  113. # match uppercase from lowercase
  114. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
  115. # offer indexes before parameters in subscripts
  116. zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
  117. # command for process lists, the local web server details and host completion
  118. #zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
  119. #zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
  120. zstyle '*' hosts $hosts
  121. # Filename suffixes to ignore during completion (except after rm command)
  122. zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
  123. '*?.old' '*?.pro'
  124. # the same for old style completion
  125. #fignore=(.o .c~ .old .pro)
  126. # ignore completion functions (until the _ignored completer)
  127. zstyle ':completion:*:functions' ignored-patterns '_*'