summaryrefslogtreecommitdiff
path: root/debian/examples/carstenh.zshrc
blob: 31df15c86518aa686f457dffa539abd17a5a9bab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# ~/.zshrc file for zsh(1).
#
# This file is sourced only for interactive shells. It should contain
# commands to set up aliases, functions, options, key bindings, etc.
#
# Global Order: zshenv, zprofile, zshrc, zlogin
#
# To enable the below-mentioned features uncomment the according lines.


# ### Include user name, host name and current working directory in the prompt:
PS1='%(!..%n@)%m:%~%# '

# ### Select emacs like key bindings:
# bindkey -e

# ### Define some useful aliases:
# { ls --help | grep -- --color } >/dev/null 2>&1 && alias ls='ls --color=auto'
# alias l='ls -F'
# alias ll='ls -F -l'
# alias la='ls -F -A'

# ### Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
# HISTSIZE=1000
# SAVEHIST=1000
# HISTFILE=~/.zsh_history

# ### Teach less, e.g., reading compressed files and listing archive content:
# which lesspipe >/dev/null && eval "$(lesspipe)"

# ### Turn on completion with the default options:
# autoload -Uz compinit; compinit
# ### Enable completion menu:
# zstyle ':completion:*' menu select=2
# ### Activate colored completion:
# which dircolors >/dev/null && eval "$(dircolors -b)"
# zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}

# ### If we are in a Debian chroot display its name in the prompt:
# [[ -r /etc/debian_chroot ]] && : ${debian_chroot:="$(cat /etc/debian_chroot)"}
# PS1="${debian_chroot:+($debian_chroot)}%(!..%n@)%m:%~%# "

# ### Use vcs_info to include version control system information in the prompt:
# setopt prompt_subst
# autoload -Uz vcs_info; vcs_info 2>/dev/null && precmd() { vcs_info }
# PS1="${debian_chroot:+($debian_chroot)}%(!..%n@)%m:%~\${vcs_info_msg_0_}%# "
# ### Configure vcs_info to be colorful:
# zstyle ':vcs_info:*' actionformats ' %F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
# zstyle ':vcs_info:*' formats ' %F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
# zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'



# ### ########################################################################
# ### All features below this line are disabled, uncomment the according     #
# ### lines to enable them.                                                  #
# ### ########################################################################

# ### Content:
# ###  * Environment variables:
# ###     - LESS:          Set default options for less.
# ###     - GIT_PAGER:     Set pager used by git.
# ###     - GIT_EXEC_PATH: Tell git to look in ~/bin/git for git executables.
# ###     - TIMEFMT:       Set outputformat of shell builtin time.
# ###  * Zsh options:
# ###     - Not listed here.
# ###  * Precmd / preexec:
# ###     - Set xterm / rxvt title.
# ###     - Set screen's window title.
# ###     - Transparent directory replacement.
# ###  * Aliases:
# ###     - Not listed here.
# ###  * Functions:
# ###     - Start(), Restart(), Stop(), Reload(), Force-Reload():
# ###                   Start, restart, stop, reload or force-reload a System-V
# ###                   style init script.
# ###     - accessed(), changed(), modified():
# ###                   List files which have been changed / modified / accessed
# ###                   within the last n days, n defaults to 1.
# ###     - accessed.(), changed.(), modified.():
# ###                   Same as above, but list files whose name start with
# ###                   a dot.
# ###     - bk():       Make a backup of a file.
# ###     - cdt():      Create temporary directory and chdir into it.
# ###     - edalias():  Edit an alias via zle.
# ###     - edfunc():   Edit a function via zle.
# ###     - md():       Create given directory recursively and chdir into it.
# ###     - sll():      List symlinks in detail (more detailed 'readlink -f').
# ###     - unik():     Print unique lines, input does not need to be sorted.
# ###  * Misc:
# ###     - Chdir to ~ if zsh was started in a non-existent directory.
# ###     - Cat ~/dead.letter.
# ###     - Source ~/.zshrc.local if it exists and is readable.



# ### ########################################################################
# ### Environment variables:                                                 #
# ### ####################################################################{{{1

# ### Set default options for less:
# ###  -~  -- Display lines after end of file as blank lines.
# ###  -#  -- Specifies the default number of positions to scroll horizontally
# ###        in the RIGHTARROW and LEFTARROW commands.
# ###  -K  -- Causes less to exit immediately when ^C is typed.
# ###  -M  -- Causes less to prompt even more verbosely than more.
# ###  -R  -- Causes ANSI "color" escape sequences to be displayed.
# ###  -i  -- Causes searches to ignore case like vim's smartcase does.
# ###  -q  -- Use visual bell but not the terminal bell.
# ###  -w  -- Temporarily highlight the first "new" line after a forward movement.
# which less >/dev/null && export LESS='-~#20KMRiqw'

# ### Set pager used by git:
# ###  -E  -- Automatically exit the first time it reaches end-of-file.
# ###  -F  -- Automatically exit if the entire file fits on the first screen.
# ###  -X  -- Disable sending the termcap initialization and deinitialization
# ###         strings to the terminal.  Prevents clearing the screen.
# which less >/dev/null && export GIT_PAGER='less -EFX'

# ### Tell git to look in ~/bin/git for git executables:
# which git >/dev/null && export GIT_EXEC_PATH="`git --exec-path`:$HOME/bin/git"

# ### Set outputformat of shell builtin time:
# TIMEFMT="
#             Time spent in user mode:                    %U
#             Time spent in kernel mode:                  %S
#             Total time:                                 %E
#             CPU utilisation:                            %P
# "


# ### #####################################################################}}}
# ### Zsh options:                                                           #
# ### ####################################################################{{{1

# ### Changing directories:
# ### Try chdir if there is no matching executeable.
# setopt autocd
# ### Chdir to hashed directories without the need to prepend ~.
# setopt cdablevars
# ### Make cd push the old directory onto the directory stack.
# setopt autopushd
# ### Don't push multiple copies of the same directory onto the stack.
# setopt pushdignoredups
# ### Do not print the directory stack after pushd or popd.
# setopt pushdsilent
# ### Make pushd with no arguments act like `pushd $HOME'.
# setopt pushdtohome

# ### Completion:
# ### Use different widths whilst displaying completion menu to reduce size.
# setopt listpacked
# ### Try to complete when cursor is in the word.
# setopt complete_in_word
# ### Automatically list choices on an ambiguous completion.
# setopt autolist

# ### History:
# ### Don't display duplicates in while searching in history.
# setopt histfindnodups
# ### Don't put duplicate lines in history.
# setopt histignoredups
# ### Remove superfluous blanks from history.
# setopt histreduceblanks
# ### Reload line into editing buffer instead of executing it.
# setopt histverify
# ### Don't add lines prefixed by a space to history.
# setopt histignorespace

# ### Job Control:
# ### Don't nice backgrounded jobs.
# setopt nobgnice
# ### Don't send HUP signal to running jobs when the shell exists and don't
# ### complain about still running background jobs.
# setopt nohup nocheckjobs
# ### Print backgrounded jobs when they finish.
# setopt notify
# ### Disable flow-control with ^S and ^Q.
# setopt noflowcontrol

# ### Prompt:
# ### Print exitvalues != 0.
# setopt printexitvalue
# ### Send \r on new line.
# setopt promptcr

# ### Zle:
# ### Be quiet.
# setopt nobeep


# ### #####################################################################}}}
# ### Precmd / preexec:                                                      #
# ### ####################################################################{{{1

# ### Set xterm / rxvt title:
# preexec_xterm_title() {
#     [[ "$TERM" != "xterm" ]] && [[ "$TERM" == "${TERM#rxvt}" ]] && return
#     print -nR $'\033]0;'$1$'\a'
# }
# precmd_xterm_title() {
#     [[ "$TERM" != "xterm" ]] && [[ "$TERM" == "${TERM#rxvt}" ]] && return
#     print -nR $'\033]0;'Terminal$'\a'
# }
# preexec_functions=( ${preexec_functions} preexec_xterm_title )
# precmd_functions=(  ${precmd_functions}  precmd_xterm_title )

# ### Set screen's window title:
# preexec_screen_window_title() {
#     [[ "$TERM" == "${TERM#screen}" ]] && return
#     setopt localoptions extendedglob shwordsplit noksharrays
#     typeset -a cmd m_bracket m_brace m_paren m_percent
#     cmd=(${${1}[(wr)^(*=*|nice|sudo|time|env|fakeroot|trickle|-*),-1]})
#     [[ -n "$cmd[2]" ]] || { echo -ne "\ek$cmd[1]\e\\"; return; }
#     m_bracket=( vi vim emacs mcedit nano ee joe less more most )
#     m_percent=( make )
#     m_paren=( man perldoc )
#     m_brace=( )
#     local cmd1="$cmd[1]" m1 m2
#     if { [[ ${m_bracket[(i)$cmd1]} -le ${#m_bracket} ]] && m1='[' && m2=']' } \
#     || { [[ ${m_brace[(i)$cmd1]}   -le ${#m_brace}   ]] && m1='{' && m2='}' } \
#     || { [[ ${m_paren[(i)$cmd1]}   -le ${#m_paren}   ]] && m1='(' && m2=')' } \
#     || { [[ ${m_percent[(i)$cmd1]} -le ${#m_percent} ]] && m1='%' && m2='%' }
#     then
#         shift 1 cmd
#         cmd=(${${cmd}[(wr)^(*=*|-*|1|2|3|4|5|6|7|8),-1]})
#         cmd[1]="${${${${cmd[1]}##*/}%=}:-$cmd1}"
#     fi
#     echo -ne "\ek$m1$cmd[1]$m2\e\\"
# }
# precmd_screen_window_title() {
#     [[ "$TERM" == "${TERM#screen}" ]] && return
#     echo -ne "\ekzsh\e\\"
# }
# preexec_functions=( ${preexec_functions} preexec_screen_window_title )
# precmd_functions=(  ${precmd_functions}  precmd_screen_window_title )

# ### Transparent directory replacement:
# ### http://chris-lamb.co.uk/2009/11/19/transparent-directory-replacement-zsh/
# precmd_transparent_dir_replacement() {
#     [ . -ef "$PWD" ] && return 0
#     local OLDOLDPWD="$OLDPWD"
#     builtin cd -q -- "$PWD" >/dev/null 2>&1 || {
#         echo >&2 "W: $PWD does not exist anymore."
#         return 1
#     }
#     OLDPWD="$OLDOLDPWD"
# }
# precmd_functions=( ${precmd_functions} precmd_transparent_dir_replacement )


# ### #####################################################################}}}
# ### Aliases:                                                               #
# ### ####################################################################{{{1

# ### Ordinary aliases:
# { grep --help  | grep -- --color } >/dev/null 2>&1 && \
#     alias grep='grep --color=auto'
# { egrep --help | grep -- --color } >/dev/null 2>&1 && \
#     alias egrep='egrep --color=auto'
# alias cp='nocorrect cp'
# alias ln='nocorrect ln'
# alias mkdir='nocorrect mkdir'
# alias mv='nocorrect mv'
# alias rm='nocorrect rm'

# ### Suffix aliases:
# ### http://dev.codemac.net/config.git?p=config.git;a=blob;f=zsh/alias
# ### Automatically open images:
# if which feh >/dev/null; then
#     alias -s {jpg,JPG,jpeg,JPEG,png,PNG,gif,GIF}="feh -FZd"
# fi
# ### Automatically open movies:
# if which mplayer >/dev/null; then
#     alias -s {mpg,mpeg,avi,ogm,wmv,m4v,mp4,mov,3GP}="mplayer -idx"
# fi
# ### Automatically open web addresses (requires $BROWSER to be set):
# if [[ -n "$BROWSER" ]] && which "$BROWSER" >/dev/null; then
#     alias -s {html,htm,com,net,org,gov,edu,de}="$BROWSER"
# fi
# ### Automatically open text files (requires $EDITOR to be set):
# if [[ -n "$EDITOR" ]] && which "$EDITOR" >/dev/null; then
#     alias -s {txt,c,h}="$EDITOR"
# fi
# ### Automatically open other known files:
# which evince >/dev/null && alias -s pdf="evince"
# which evince >/dev/null && alias -s ps="evince"
# which java   >/dev/null && alias -s jar="java -jar"


# ### #####################################################################}}}
# ### Functions:                                                             #
# ### ####################################################################{{{1

# ### Start(), Restart(), Stop(), Reload(), Force-Reload():
# ###             Start, restart, stop, reload or force-reload a service.
# eval {Start,Restart,Stop,Reload,Force-Reload}'() { (
#     builtin cd -q / || { echo >&2 "E: Could not chdir to /"; return 1; }
#     env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
#     service "${1:?}" "${0:l}"
# ) };'
# compctl -g "/etc/init.d/*(:t)" Start Restart Stop Reload Force-Reload

# ### accessed(), changed(), modified():
# ###             List files which have been changed / modified / accessed
# ###             within the last n days, n defaults to 1.
# accessed()  { emulate -L zsh; print -l -- *(a-${1:-1}); }
# changed()   { emulate -L zsh; print -l -- *(c-${1:-1}); }
# modified()  { emulate -L zsh; print -l -- *(m-${1:-1}); }
# ### accessed.(), changed.(), modified.():
# ###             Same as above, but list files whose name starts with
# ###             a dot.
# accessed.() { emulate -L zsh; print -l -- .*(a-${1:-1}); }
# changed.()  { emulate -L zsh; print -l -- .*(c-${1:-1}); }
# modified.() { emulate -L zsh; print -l -- .*(m-${1:-1}); }

# ### bk():       Make a backup of a file.
# bk() {
#     cp -a "$1" "${1}_$(date --iso-8601=seconds)";
# }

# ### cdt():      Create temporary directory and chdir into it.
# cdt() {
#     [[ $# -eq 0 ]] || printf 'Usage: %s\n' "$0";
#     builtin cd "$(mktemp -t -d cdt.XXXXXXXXXX)";
# }

# ### edalias():  Edit an alias via zle.
# edalias() {
#    [[ -z "$1" ]] && { echo "Usage: edalias <alias_to_edit>" ; return 1 }
#    vared aliases'[$1]'
# }
# compdef _aliases edalias

# ### edfunc():   Edit a function via zle.
# edfunc() {
#    [[ -z "$1" ]] && { echo "Usage: edfun <function_to_edit>" ; return 1 }
#    zed -f "$1"
# }
# compdef _functions edfunc

# ### md():       Create given directory recursively and chdir into it.
# md() {
#     [[ $# -eq 1 ]] || printf 'Usage: %s <directory>\n' "$0";
#     mkdir -p "$1" && builtin cd "$1";
# }
# compdef md=mkdir

# ### sll():      List symlinks in detail (more detailed 'readlink -f').
# sll() {
#     [[ -z "$1" ]] && printf 'Usage: %s <file(s)>\n' "$0" && return 1
#     local file
#     for file in "$@"; do
#     (
#         while [[ -h "$file" ]]; do
#             ls -l "$file"
#             builtin cd -q "${file:h}"
#             file="$(readlink "${file:t}")"
#         done
#         ls -l "$file"
#     )
#     done
# }

# ### unik():     Print unique lines, input does not need to be sorted.
# unik() {
#     perl -ne 'print unless $seen{$_}++' "$@"
# }


# ### #####################################################################}}}
# ### Misc:                                                                  #
# ### ####################################################################{{{1

# ### Chdir to ~ if zsh was started in a non-existent directory:
# [[ "$PWD" == . ]] && builtin cd ~

# ### Cat ~/dead.letter:
# if [[ -r ~/dead.letter ]]; then
#     echo ~/dead.letter:
#     cat  ~/dead.letter
#     echo
# fi
# if [[ "$USERNAME" == root ]] && [[ -r /dead.letter ]]; then
#     echo /dead.letter:
#     cat  /dead.letter
#     echo
# fi

# ### Source ~/.zshrc.local if it exists and is readable:
# [[ -r ~/.zshrc.local ]] && . ~/.zshrc.local || true