-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbash_prompt
74 lines (62 loc) · 1.97 KB
/
bash_prompt
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
# check http://misc.flogisoft.com/bash/tip_colors_and_formatting#colors1 for
# color numbers.
style_normal=$(tput sgr0)
style_name_at_host=$(tput setaf 240)
style_workspace_dir=$(tput bold; tput setaf 77)
style_other_dir=$(tput bold; tput setaf 260)
style_ruby=$(tput setaf 9)
style_node=$(tput setaf 2)
style_python=$(tput setaf 10)
style_ssh_flag="$(tput setab 118; tput setaf 0) ssh $style_normal "
function print_pre_prompt {
local color=''
local dir="$PWD"
local spacing_correction=-64 # correction for left & right
if [[ "x$WORKSPACE" != "x" ]]; then
if [[ $PWD == $WORKSPACE* ]] ; then
color=$style_workspace_dir
dir=${PWD/$WORKSPACE\//\(work\) }
else
color=$style_other_dir
dir=${PWD/$HOME/\~}
fi
fi
local ssh_flag=''
if [ -n "$SSH_CLIENT" ] ; then
ssh_flag="$style_ssh_flag"
spacing_correction=$(($spacing_correction - 22))
fi
local python=''
if [[ -z "$PROMPT_NO_PYTHON" ]]; then
python="$(__pyenv_ps1 2> /dev/null)"
if [[ "x$python" != "x" ]]; then
python="(${style_python} ${python}${style_normal}) "
fi
fi
local ruby=''
if [[ -z "$PROMPT_NO_RUBY" ]]; then
ruby="$(__rbenv_ps1 2> /dev/null)"
if [[ "x$ruby" != "x" ]]; then
ruby="(${style_ruby} ${ruby}${style_normal}) "
fi
fi
local nvm=''
if [[ -z "$PROMPT_NO_NVM" ]]; then
nvm="$(__nvm_ps1 2> /dev/null)"
if [[ "x$nvm" != "x" ]]; then
nvm="(${style_node} ${nvm}${style_normal})"
fi
fi
local left="${ssh_flag}${style_name_at_host}$USER@$HOSTNAME${style_normal} ${color}$dir${style_normal} $(__git_ps1 ' %s')"
local right="${python}${ruby}${nvm}"
if [[ "x$right" == "x" ]]; then
spacing_correction=0
fi
printf "%s%$(($COLUMNS-${#left}-$spacing_correction))s\n" "$left" "$right"
}
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM=1
PROMPT_COMMAND=print_pre_prompt
PS1='$ '