-
Notifications
You must be signed in to change notification settings - Fork 0
/
zprofile
144 lines (126 loc) · 3.08 KB
/
zprofile
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
# vi: set ft=zsh :
# export TERM=vt100
export DOTFILES="$HOME/.dotfiles"
export PATH="$DOTFILES/bin:$PATH"
export PROJECTS="$HOME/Projects"
if [[ -d "$HOME/.bin" ]]; then
export PATH="$HOME/.bin:$PATH"
fi
if [[ -d "$HOME/Library/Python/2.7/lib/python/site-packages/powerline" ]]; then
export POWERLINE="$HOME/Library/Python/2.7/lib/python/site-packages/powerline"
fi
export RUBY_ENV="development"
export RACK_ENV="development"
export RAILS_ENV="development"
export NODE_ENV="development"
export NPM_ENV="development"
# Local config
[[ -f $HOME/.zprofile.local ]] && source $HOME/.zprofile.local
# Load RVM if available
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]]; then
source "/usr/local/rvm/scripts/rvm"
elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
# Load NVM if possible
NVM_DIR="$HOME/.nvm"
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
source "$NVM_DIR/nvm.sh"
export NVM_DIR
fi
# sets the color of the Git branch to red if dirty
git_prompt_color() {
st=$(git status 2>/dev/null | tail -n 1)
if [[ $st == '' ]] || [[ $st =~ ^nothing ]];
then
echo 'green'
else
echo 'red'
fi
}
# adds the current branch name in green
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[%{$fg_bold[$(git_prompt_color)]%}${ref#refs/heads/}%{$reset_color%}]"
fi
}
# Adds the current Ruby version
ruby_version() {
if (( $+commands[rbenv] ))
then
echo "$(rbenv version | awk '{print $1}')"
elif (( $+commands[rvm-prompt] ))
then
echo "$(rvm-prompt | awk '{print $1}')"
elif (( $+commands[ruby] ))
then
echo "$(ruby -v | awk '{print $1 "-" $2}')"
else
echo ""
fi
}
rb_prompt() {
if ! [[ -z "$(ruby_version)" ]]
then
echo "%{$fg_bold[blue]%}$(ruby_version)%{$reset_color%}"
else
echo ""
fi
}
# Adds the current Node version
node_version() {
if [ $(declare -f nvm_version > /dev/null; echo $?) == 0 ]
then
echo "nodejs-$(nvm_version)"
elif (( $+commands[iojs] ))
then
echo "iojs-$(iojs --version)"
elif (( $+commands[node] ))
then
echo "node-$(node --version)"
else
echo ""
fi
}
node_prompt() {
if ! [[ -z "$(node_version)" ]]
then
echo "%{$fg_bold[blue]%}$(node_version)%{$reset_color%}"
fi
}
# Adds the current Elixir version
ex_version() {
if (( $+commands[kiex] ))
then
echo "$(kiex list | grep = | grep -v \# | awk '{ print $2 }')"
elif (( $+commands[elixir] ))
then
echo "$(elixir --version | tail -n 1)"
fi
}
ex_prompt() {
if ! [[ -z "$(ex_version)" ]];
then
echo "%{$fg_bold[blue]%}$(ex_version)%{$reset_color%}"
fi
}
# makes color constants available
autoload -U colors
colors
# enable colored output from ls, etc
export CLICOLOR=1
# expand functions in the prompt
setopt promptsubst
# prompt
export PROMPT='$(git_prompt_info)[${SSH_CONNECTION+"%{$fg_bold[blue]%}%n@%m:"}%{$fg_bold[cyan]%}%~%{$reset_color%}]
§ '
set_prompt () {
# export RPROMPT="[$(ex_prompt)][$(rb_prompt)][$(node_prompt)]"
}
precmd () {
set_prompt
}