-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbash_prompt
27 lines (22 loc) · 878 Bytes
/
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
function parse_git_dirty () {
# ?? file.txt # Unstaged new files
# A file.txt # Staged new files
# M file.txt # Unstaged modified files
# M file.txt # Staged modified files
# D file.txt # Unstaged deleted files
# D file.txt # Staged deleted files
# If the git status has *any* changes (i.e. dirty)
if [[ -n "$(git status --porcelain 2> /dev/null)" ]]; then
# echo our character
echo " ↺"
fi
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# prompt with ruby version
function rbenv_version() {
rbenv version 2> /dev/null | sed 's/\([^ ]*\).*/(\1)/'
}
export PS1="\u@\h\[$RESET\] \$(rbenv_version) \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" ➞ \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
export PS2="\[$RED\]→ \[$RESET\]"