-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
148 lines (128 loc) · 3.61 KB
/
zshrc
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
# Definition du PATH
PATH=$HOME/http/bin:$HOME/.npm/bin:$HOME/scripts:$HOME/.brew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin
export PATH
export HOMEBREW_CACHE=/tmp/mycache
export HOMEBREW_TEMP=/tmp/mytemp
# Configuration de l'historique
HISTFILE=~/.zshrc_history
SAVEHIST=5000
HISTSIZE=5000
setopt inc_append_history
setopt share_history
# Tmux command history
bindkey '^R' history-incremental-search-backward
bindkey -e
export LC_ALL=en_US.UTF-8
# search in history based on what is type
bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward
# previous/next word with ctrl + arrow
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# default editor
EDITOR=/usr/bin/vim
export EDITOR
# Reglage du terminal
if [ "$SHLVL" -eq 1 ]; then
TERM=xterm-256color
fi
# Correction de la touche Delete
bindkey "\e[3~" delete-char
# add completion provied by bin installed via brew
if [[ -d "$HOME/.brew/share/zsh/site-functions/" ]]; then
fpath=($HOME/.brew/share/zsh/site-functions/ $fpath)
fi
# Autocompletion amelioree
autoload -U compinit && compinit
# Autocompletion de type menu
zstyle ':completion:*' menu select
# Couleur prompt
autoload -U colors && colors
# fucking mac and their /Volume/<hdd_name>
cd "`echo $PWD | sed 's:/Volumes/Data::'`"
# Definition des variables
USER=`/usr/bin/whoami`
export USER
GROUP=`/usr/bin/id -gn $user`
export GROUP
MAIL="[email protected]"
export MAIL
LIB="$HOME/libft"
export LIB
# Definition des couleurs
if [ -f ~/.ls_colors ]; then
source ~/.ls_colors
fi
NORMAL="%{$reset_color%}"
# Definition du prompt
precmd ()
{
if [ $? -eq 0 ]
then
COLOR3="%{$fg[green]%}"
else
COLOR3="%{$fg[red]%}"
fi
ISGIT=$(git status 2> /dev/null)
if [ -n "$ISGIT" ]
then
STATUS=$(echo "$ISGIT" | grep "modified:\|renamed:\|new file:\|deleted:" | grep -v ".vim/bundle\|untracked")
BRANCH=$(git branch | cut -d ' ' -f 2 | tr -d '\n')
if [ -n "$STATUS" ]
then
COLOR="%{$fg[red]%}"
else
REMOTE_EXIST=$(git branch -a | grep remotes/origin/$BRANCH)
if [ -n "$REMOTE_EXIST" ]
then
REMOTE=$(git diff origin/$BRANCH)
if [ -n "$REMOTE" ]
then
COLOR="%{$fg[yellow]%}"
else
COLOR="%{$fg[green]%}"
fi
else
COLOR="%{$fg[green]%}"
fi
fi
RPROMPT="%{$COLOR%}($BRANCH)%{$NORMAL%}"
else
RPROMPT=""
fi
PROMPT="%B%{$fg[green]%}%n@%m%{$NORMAL%}%B:%{$fg[blue]%}%~%{$NORMAL%}
%B%{$COLOR3%}> %{$NORMAL%}%b"
}
# Load global aliases
if [ -f ~/.aliases ]; then
source ~/.aliases
fi
# Couleurs pour le man
man()
{
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# update symlink in case of zsf change
if [[ ! -f $HOME/.old_home ]]; then
echo $HOME > $HOME/.old_home
fi
OLD_HOME=$(cat $HOME/.old_home)
if [[ "$OLD_HOME" != "$HOME" ]]; then
echo $HOME > $HOME/.old_home
if [[ `basename $HOME` = "mdelage" ]]; then
env GEAM=true $HOME/.dotfiles/install.sh -c -l
else
$HOME/.dotfiles/install.sh -c -l
fi
echo "+------------------------+"
echo "| /!\\ You've changed zsf |"
echo "+------------------------+"
fi