guest@dotshare [~/groups/shells/zsh] $ ls a-convenient-zshrc/ | cat

a convenient zshrc (raw, dl)

kamaradclimber Jun 23, 2011 (shells/zsh)
  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
# ~/.zshrc: Personal settings for zsh

####################
# Personal aliases #
####################

alias bidounet=192.168.1.71
alias sshb='ssh grego@bidounet'


# Secure SHell access to some machines



######################
# Personal functions #
######################

case $TERM in
   xterm*)
          precmd () {print -Pn "\e]0;%n@%m: %~\a"}
                 ;;
                 esac



# Locales {{{
export LANG=en_US.utf8
export LANGUAGE=en_US.utf8
export LC_ADDRESS=en_US.utf8
export LC_ALL=en_US.utf8
export LC_COLLATE=en_US.utf8
export LC_IDENTIFICATION=en_US.utf8
export LC_MESSAGES=en_US.utf8
export LC_MEASUREMENT=en_US.utf8
export LC_MONETARY=en_US.utf8
export LC_NAME=en_US.utf8
export LC_NUMERIC=en_US.utf8
export LC_PAPER=en_US.utf8
export LC_TELEPHONE=en_US.utf8
export LC_TIME=en_US.utf8
export LC_TYPE=en_US.utf8

#unicode_start
# }}}


# Constants {{{
export COLORTERM="yes"
export EDITOR="/usr/bin/vim"
export GREP_COLOR=31
export HISTORY=1000
export MAIL=${HOME}/mail
export MAILCHECK=1
export PATH=/usr/share/perl5/vendor_perl/auto/share/dist/Cope:${PATH}
export SAVEHIST=1000
export GDK_USE_XFT=1    #   For old gtk applications
export QT_XFT=true      #   For old qt applicatios
# }}}



# Keybindings {{{


bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[4~" end-of-line # End
bindkey "\e[5~" beginning-of-history # PageUp
bindkey "\e[6~" end-of-history # PageDown
bindkey "\e[2~" quoted-insert # Ins
bindkey "\e[3~" delete-char # Del
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
# for rxvt
bindkey "\e[7~" beginning-of-line # Home
bindkey "\e[8~" end-of-line # End
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line

bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
# }}}


autoload -U compinit; compinit

zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no result for : %d%b'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s

# Remove trailing slashes
zstyle ':completion:*' squeeze-slashes true

# Use cache
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh_cache

# Prevent CVS files/directories from being completed
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'

# Allow mistakes
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
#zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'

# [?] Ignore completion functions for commands you don’t have
zstyle ':completion:*:functions' ignored-patterns '_*'

# Colors
# You can also add different colours to the completion list - as displayed in the screenshot below. To be more specific, we'll use the same colours that GNU ls shows with the --color option
zmodload zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}

# Do not show already selected elements
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:mv:*' ignore-line yes
zstyle ':completion:*:cp:*' ignore-line yes

#   Sudo completion
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
    /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin

# PID completion
zstyle ':completion:*:*:kill:*:processes'   list-colors "=(#b) #([0-9]#)*=36=31"
zstyle ':completion:*:*:kill:*'             menu yes select
zstyle ':completion:*:kill:*'               force-list always
zstyle ':completion:*:*:killall:*'          menu yes select
zstyle ':completion:*:killall:*'            force-list always
zstyle ':completion:*:processes'            command "ps -au$USER"

# Don't select parent directory on cd
zstyle ':completion:*:cd:*' ignore-parents parent pwd

# xdvi completion
zstyle ':completion:*:*:xdvi:*' menu yes select
zstyle ':completion:*:*:xdvi:*' file-sort time

#   Support des fonctions de complétion de bash
autoload -U bashcompinit; bashcompinit
# }}}

# Prompts {{{

# Enable preconfigured prompts
#autoload -U promptinit
#promptinit
#prompt adam2

BLACK="%{"$'\033[01;30m'"%}"
RED="%{"$'\033[01;31m'"%}"
GREEN="%{"$'\033[01;32m'"%}"
YELLOW="%{"$'\033[01;33m'"%}"
BLUE="%{"$'\033[01;34m'"%}"
MAGENTA="%{"$'\033[01;35m'"%}"
CYAN="%{"$'\033[01;36m'"%}"
BOLD="%{"$'\033[01;39m'"%}"
NORM="%{"$'\033[00m'"%}"

export PS1="[%T] ${RED}%n${NORM}@${BLUE}%m${NORM}:${YELLOW}%~${NORM} %#>"
# }}}

# Aliases {{{
#alias du='du -chs'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
alias ls='ls --tabsize=0 --literal --color=auto --show-control-chars --human-readable --group-directories-first -X'
alias mkdir='mkdir -p -v'
alias mv='mv -v'
alias o='xdg-open'
alias pingg='ping www.google.fr'
alias suvim='sudo vim'
alias volume='alsamixer -c 0'

if [ $UID -ne 0 ]; then
    alias reboot='sudo reboot'
    alias halt='sudo halt'
fi

# File extension => application
alias -s tex=vim
alias -s pdf=epdfview


# Options {{{
setopt auto_cd  
setopt hist_ignore_all_dups     #   Anti-doublon dans l'historique
setopt hist_ignore_space        #   Do not save commands that start with a space
setopt inc_append_history
#setopt correctall              #   Correction of writing errors (ex: sl => ls)
setopt autopushd pushdminus pushdsilent pushdtohome
setopt cdablevars
#setopt ignoreeof               #   Prevent from using Ctrl + d
setopt interactivecomments
#setopt nobanghist
setopt noclobber
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_SPACE
setopt SH_WORD_SPLIT
setopt nohup
setopt chase_links              #   Traite les liens symboliques comme il faut

#   Quand l'utilisateur commence sa commande par '!' pour faire de la
#   complétion historique, il n'exécute pas la commande immédiatement
#   mais il écrit la commande dans le prompt
setopt hist_verify

setopt extendedglob             #   Use regexp in commands (ex : cp ^*.(tar|bz2|gz))

#   No beeps at all !
unsetopt beep
unsetopt hist_beep
unsetopt list_beep

#   Si on utilise des jokers dans une liste d'arguments, retire les jokers
#   qui ne correspondent à rien au lieu de donner une erreur
setopt nullglob



unalias run-help
autoload run-help


#   Inline completion
set always_to_end
# }}}


##Coloring man pages
man() {
	env \
		LESS_TERMCAP_mb=$(printf "\e[1;37m") \
		LESS_TERMCAP_md=$(printf "\e[1;37m") \
		LESS_TERMCAP_me=$(printf "\e[0m") \
		LESS_TERMCAP_se=$(printf "\e[0m") \
		LESS_TERMCAP_so=$(printf "\e[1;47;30m") \
		LESS_TERMCAP_ue=$(printf "\e[0m") \
		LESS_TERMCAP_us=$(printf "\e[0;36m") \
			man "$@"
}

CLICK TO VIEW

x

Notes

Completion for sudo, aptitude, …

good colors

need cope to works properly