-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_prompt
More file actions
37 lines (30 loc) 路 1.12 KB
/
Copy path.bash_prompt
File metadata and controls
37 lines (30 loc) 路 1.12 KB
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
#!/usr/bin/env bash
get_current_git_branch() {
local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [ -n "$branch" ]; then
local prompt=" ("
local status=$(git status --porcelain 2>/dev/null)
if [ -n "$status" ]; then
prompt+="\033[0;33m$branch\033[0m*" # Yellow
else
prompt+="\033[0;32m$branch\033[0m" # Green
fi
local ahead=$(git rev-list --count @{u}.. 2>/dev/null)
local behind=$(git rev-list --count ..@{u} 2>/dev/null)
[ "${ahead:-0}" -gt 0 ] && prompt+=" $ahead+"
[ "${behind:-0}" -gt 0 ] && prompt+=" $behind-"
prompt+=")"
echo -e "$prompt"
fi
}
# \[\e[0;93m\]: yellow
# \u: username
# \[\e[m\]: reset
# \[\e[0;95m\]: purple
# \W: current directory
# \$(get_current_git_branch): git branch name (if any)
PS1="\[\e[0;93m\]\u\[\e[m\] \[\e[0;95m\]\W\[\e[m\]\$(get_current_git_branch) > "
export PS1
export CLICOLOR=1 # Enable colors
export LSCOLORS=ExFxBxDxCxegedabagacad # Define colors schema
export BASH_SILENCE_DEPRECATION_WARNING=1 # Disable deprecation warnings on macOS