[zsh]get inspiration from oh_my_zsh

This commit is contained in:
Mathieu Maret 2014-08-02 01:08:24 +02:00
parent d051ea46a5
commit 4976ec5c47
3 changed files with 43 additions and 2 deletions

View File

@ -11,10 +11,15 @@ setopt -h histappend
PROMPT_COMMAND='history -a'
setopt append_history autocd extendedglob nomatch
setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space # ignore line starting by a space
setopt share_history # share command history data
#Doing this, only past commands beginning with the current input would've been shown.
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
unsetopt beep
#force emacs binding for tmux && screen
@ -38,14 +43,36 @@ prompt bart
# pushd pour cd
setopt autopushd
setopt pushd_ignore_dups
# ne tue pas les processus quand zsh quitte
#setopt nohup
# auto cd avec le nom du dossier
setopt autocd
#Un grep avec des couleurs :
export GREP_COLOR=31
alias grep='grep --color=auto'
#export GREP_COLOR=31
#alias grep='grep --color=auto'
GREP_OPTIONS="--color=auto"
# avoid VCS folders (if the necessary grep flags are available)
grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1
}
if grep-flag-available --exclude-dir=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude-dir=$PATTERN"
done
elif grep-flag-available --exclude=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude=$PATTERN"
done
fi
unfunction grep-flag-available
export GREP_OPTIONS="$GREP_OPTIONS"
export GREP_COLOR='1;31'
# support des type mimes -> ./toto.pdf
autoload -U zsh-mime-setup

View File

@ -3,6 +3,16 @@ zstyle :compinstall filename '$HOME/.zshrc'
autoload -Uz compinit
compinit
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
# Color in completion
zstyle ':completion:*' list-colors ''
# Crée un cache des complétion possibles
# très utile pour les complétion qui demandent beaucoup de temps
@ -27,6 +37,7 @@ zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
zmodload zsh/complist
setopt extendedglob
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
#completion des hosts avec le contenue de know_hosts
#local _myhosts

View File

@ -142,3 +142,6 @@ croot ()
fi
}
function zsh_stats() {
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
}