1 # Filename: /etc/skel/.zshrc
2 # Purpose: config file for zsh (z shell)
3 # Authors: (c) grml-team (grml.org)
4 # Bug-Reports: see http://grml.org/bugs/
5 # License: This file is licensed under the GPL v2 or any later version.
6 ################################################################################
7 # Nowadays, grml's zsh setup lives in only *one* zshrc file.
8 # That is the global one: /etc/zsh/zshrc (from grml-etc-core).
9 # It is best to leave *this* file untouched and do personal changes to
10 # your zsh setup via ${HOME}/.zshrc.local which is loaded at the end of
13 # That way, we enable people on other operating systems to use our
14 # setup, too, just by copying our global zshrc to their ${HOME}/.zshrc.
15 # Adjustments would still go to the .zshrc.local file.
16 ################################################################################
18 ## Inform users about upgrade path for grml's old zshrc layout, assuming that:
19 ## /etc/skel/.zshrc was installed as ~/.zshrc,
20 ## /etc/zsh/zshrc was installed as ~/.zshrc.global and
21 ## ~/.zshrc.local does not exist yet.
22 if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then
24 printf '-!- Looks like you are using the old zshrc layout of grml.\n'
25 printf '-!- Please read the notes in the grml-zsh-refcard, being'
26 printf '-!- available at: http://grml.org/zsh/\n'
28 printf '-!- If you just want to get rid of this warning message execute:\n'
29 printf '-!- touch ~/.zshrc.local\n'
34 #if (( EUID == 0 )); then
40 ## Now, we'll give a few examples of what you might want to use in your
41 ## .zshrc.local file (just copy'n'paste and uncomment it there):
43 ## Prompt theme extension ##
47 #function virtual_env_prompt () {
48 # REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
50 #grml_theme_add_token virtual-env -f virtual_env_prompt '%F{magenta}' '%f'
51 #zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent
55 ## use the vi navigation keys (hjkl) besides cursor keys in menu completion
56 #bindkey -M menuselect 'h' vi-backward-char # left
57 #bindkey -M menuselect 'k' vi-up-line-or-history # up
58 #bindkey -M menuselect 'l' vi-forward-char # right
59 #bindkey -M menuselect 'j' vi-down-line-or-history # bottom
61 ## set command prediction from history, see 'man 1 zshcontrib'
62 #is4 && zrcautoload predict-on && \
63 #zle -N predict-on && \
64 #zle -N predict-off && \
65 #bindkey "^X^Z" predict-on && \
66 #bindkey "^Z" predict-off
68 ## press ctrl-q to quote line:
70 # zle beginning-of-line
72 # # RBUFFER="'$RBUFFER'"
73 # RBUFFER=${(q)RBUFFER}
76 #zle -N mquote && bindkey '^q' mquote
78 ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..)
79 #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default
81 #WORDCHARS='*?_[]~=&;!#$%^(){}'
82 #WORDCHARS='${WORDCHARS:s@/@}'
84 # just type '...' to get '../..'
87 #if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
95 #zle -N rationalise-dot
96 #bindkey . rationalise-dot
97 ## without this, typing a . aborts incremental history search
98 #bindkey -M isearch . self-insert
100 #bindkey '\eq' push-line-or-edit
102 ## some popular options ##
104 ## add `|' to output redirections in the history
105 #setopt histallowclobber
107 ## warning if file exists ('cat /dev/null > ~/.zshrc')
110 ## don't warn me about bg processes when exiting
113 ## alert me if something failed
114 #setopt printexitvalue
116 ## with spelling correction, assume dvorak kb
119 ## Allow comments even in interactive shells
120 #setopt interactivecomments
123 ## compsys related snippets ##
125 ## changed completer settings
126 #zstyle ':completion:*' completer _complete _correct _approximate
127 #zstyle ':completion:*' expand prefix suffix
129 ## another different completer setting: expand shell aliases
130 #zstyle ':completion:*' completer _expand_alias _complete _approximate
132 ## to have more convenient account completion, specify your logins:
134 # {grml,grml1}@foo.invalid
135 # grml-devel@bar.invalid
138 # {fred,root}@foo.invalid
141 #zstyle ':completion:*:my-accounts' users-hosts $my_accounts
142 #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
144 ## add grml.org to your list of hosts
146 #zstyle ':completion:*:hosts' hosts $hosts
148 ## telnet on non-default ports? ...well:
149 ## specify specific port/service settings:
150 #telnet_users_hosts_ports=(
153 # @mail-server:{smtp,pop3}
157 #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
159 ## the default grml setup provides '..' as a completion. it does not provide
160 ## '.' though. If you want that too, use the following line:
161 #zstyle ':completion:*' special-dirs true
166 #alias u='translate -i'
168 ## ignore ~/.ssh/known_hosts entries
169 #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
172 ## global aliases (for those who like them) ##
174 #alias -g '...'='../..'
175 #alias -g '....'='../../..'
176 #alias -g BG='& exit'
180 #alias -g Hl=' --help |& less -r'
183 #alias -g LL='|& less -r'
185 #alias -g N='&>/dev/null'
186 #alias -g R='| tr A-z N-za-m'
187 #alias -g SL='| sort | less'
190 #alias -g V='| vim -'
192 ## instead of global aliase it might be better to use grmls $abk assoc array, whose contents are expanded after pressing ,.
193 #$abk[SnL]="| sort -n | less"
195 ## get top 10 shell commands:
196 #alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
198 ## Execute \kbd{./configure}
199 #alias CO="./configure"
201 ## Execute \kbd{./configure --help}
202 #alias CH="./configure --help"
204 ## miscellaneous code ##
206 ## Use a default width of 80 for manpages for more convenient reading
207 #export MANWIDTH=${MANWIDTH:-80}
209 ## Set a search path for the cd builtin
212 ## variation of our manzsh() function; pick you poison:
213 #manzsh() { /usr/bin/man zshall | most +/"$1" ; }
215 ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
217 # NO_SWITCH="yes" command bash "$@"
220 # exec $SHELL $SHELL_ARGS "$@"
223 ## Handy functions for use with the (e::) globbing qualifier (like nt)
224 #contains() { grep -q "$*" $REPLY }
225 #sameas() { diff -q "$*" $REPLY &>/dev/null }
226 #ot () { [[ $REPLY -ot ${~1} ]] }
228 ## get_ic() - queries imap servers for capabilities; real simple. no imaps
232 # if [[ ! -z $1 ]] ; then
234 # print "querying imap server on $1:${port}...\n";
235 # print "a1 capability\na2 logout\n" | nc $1 ${port}
237 # print "usage:\n $0 <imap-server> [port]"
241 ## List all occurrences of programm in current PATH
244 # if [[ $# = 0 ]] ; then
245 # echo "Usage: $0 program"
246 # echo "Example: $0 zsh"
247 # echo "Lists all occurrences of program in the current PATH."
249 # ls -l ${^path}/*$1*(*N)
253 ## Find out which libs define a symbol
255 # if [[ -n "$1" ]] ; then
256 # nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
258 # echo "Usage: lcheck <function>" >&2
262 ## Download a file and display it locally
265 # if ! [[ -n "$1" ]] ; then
266 # print "Usage: uopen \$URL/\$file">&2
270 # MIME=$(curl --head $FILE | \
271 # grep Content-Type | \
272 # cut -d ' ' -f 2 | \
275 # curl $FILE | see ${MIME}:-
281 # ps aux | awk '{if (NR > 1) print $5;
282 # if (NR > 2) print "+"}
283 # END { print "p" }' | dc
286 ## print hex value of a number
289 # if [[ -n "$1" ]]; then
292 # print 'Usage: hex <number-to-convert>'
297 ## log out? set timeout in seconds...
298 ## ...and do not log out in some specific terminals:
299 #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then
305 ## associate types and extensions (be aware with perl scripts and anwanted behaviour!)
306 #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup }
307 #alias -s pl='perl -S'
309 ## ctrl-s will no longer freeze the terminal.
312 ## you want to automatically use a bigger font on big terminals?
313 #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then
317 ## Some quick Perl-hacks aka /useful/ oneliner
318 #bew() { perl -le 'print unpack "B*","'$1'"' }
319 #web() { perl -le 'print pack "B*","'$1'"' }
320 #hew() { perl -le 'print unpack "H*","'$1'"' }
321 #weh() { perl -le 'print pack "H*","'$1'"' }
322 #pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
323 #getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
324 #gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
325 #getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
326 #getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
327 #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
328 #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
329 #showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
330 #vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
331 #vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
333 function openfoam_version_prompt () {
334 REPLY="%U(OF:$WM_PROJECT_VERSION-$WM_COMPILE_OPTION)%u "
336 grml_theme_add_token ofversion -f openfoam_version_prompt '%F{magenta}' '%f'
338 zstyle ':prompt:grml:left:setup' items rc ofversion change-root user at host path vcs percent
339 zstyle ':prompt:grml-large:left:setup' items rc jobs history shell-level change-root time date newline ofversion user at host path vcs percent
343 ## END OF FILE #################################################################