Mon .zshrc
Posté le mer. 05 août 2015 dans Linux
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 | #!/usr/bin/env zsh
# ------------------------------------------------------------------------------
# Personnalisation de ZSH
# ------------------------------------------------------------------------------
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
autoload -Uz compinit
compinit
zstyle ':completion:*' completer _expand _complete
# case-insensitive (uppercase from lowercase) completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'm:{aqwz}={qazw}'
zstyle ':completion:*' max-errors 2 numeric
# Home /del etc keybindings:
[[ -z "$terminfo[kdch1]" ]] || bindkey -M emacs "$terminfo[kdch1]" delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]" beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
[[ -z "$terminfo[kich1]" ]] || bindkey -M emacs "$terminfo[kich1]" overwrite-mode
# When last completion char is '/' and space is hit, the slash is removed:
setopt auto_remove_slash
# ------------------------------------------------------------------------------
# Personnalisation du PS1
# ------------------------------------------------------------------------------
# ZSH specific coloring scheme:
autoload -U colors && colors
sep_col="grey"
user_col="yellow"
is_col="green"
os_col="blue"
path_col="red"
date_col="cyan"
no_col="%{$reset_color%}"
# Variables à afficher
separator="%{$fg[$sep_col]%}"
for ((i=0; i<80 ; i+=1)) ; do separator=$separator"━" ; done
separator=$separator"$no_col"
if [[ `whoami` = 'spomared' ]] ; then
userName="%{$fg[$user_col]%}%n$no_col"
else
userName="%{$fg_bold[$user_col]%}%n$no_col"
fi
is="%{$fg[$is_col]%}%m$no_col"
distrib=`python2 -c "import platform ; print ' '.join(platform.linux_distribution())"`
osName="%{$fg[$os_col]%} ($distrib)$no_col"
curPath="%{$fg[$path_col]%}%~$no_col"
dateTime="%{$fg[$date_col]%}le %D{%d/%m/%y} à %*$no_col"
level=""
for ((i=1; i<$SHLVL ; i+=1)) ; do level=$level"■" ; done
PS1="$separator"$'\n'"[$userName@$is$osName $curPath $dateTime]"$'\n'"$level▶ " # '
export PS1
# ------------------------------------------------------------------------------
# Personnalisation du RPS1 pour GIT
# ------------------------------------------------------------------------------
setopt prompt_subst
autoload -U colors && colors # Enable colors in prompt
# Modify the colors and symbols in these variables as desired.
GIT_PROMPT_SYMBOL="%{$fg[blue]%}±"
GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$reset_color%}"
GIT_PROMPT_SUFFIX="%{$fg[green]%}]%{$reset_color%}"
GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}"
GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}"
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}"
GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}◒%{$reset_color%}"
GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}⚑%{$reset_color%}"
GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
# Show Git branch/tag, or name-rev if on detached head
parse_git_branch() {
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
}
# Show different symbols as appropriate for various Git repository states
parse_git_state() {
# Compose this value via multiple conditional appends.
local GIT_STATE=""
local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')"
if [ "$NUM_AHEAD" -gt 0 ]; then
GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD}
fi
local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')"
if [ "$NUM_BEHIND" -gt 0 ]; then
GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND}
fi
local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)"
if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING
fi
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED
fi
if ! git diff --quiet 2> /dev/null; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED
fi
if ! git diff --cached --quiet 2> /dev/null; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED
fi
if [[ -n $GIT_STATE ]]; then
echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX"
fi
}
# If inside a Git repository, print its branch and state
git_prompt_string() {
if [ "x$NO_GIT_PROMPT" = "x" ]; then
local git_where="$(parse_git_branch)"
[ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[green]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX"
fi
}
# Set the right-hand prompt
RPS1='$(git_prompt_string)'
# ------------------------------------------------------------------------------
# Alias et fonctions personnels
# ------------------------------------------------------------------------------
alias .=source
alias ls='ls -h --color'
alias ll='ls -Bl'
alias la='ls -Bla'
alias l='ll'
alias lldate='ll *`date +%Y-%m-%d`*'
alias rm='rm -i'
alias nbproc='cat /proc/cpuinfo | grep processor | wc -l'
alias fini='notify-send "Fini" "Tâche terminée" --icon=dialog-information'
function up
{ # permet de remonter de plusieurs repertoires
if [[ $# < 1 ]]
then depth=1
else depth=$1
fi
for i in `seq $depth`
do
cd ..
done
}
function mkcd
{ # permet de creer un repertoire et de s'y deplacer
mkdir -p $@
cd $@
}
|