-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt
More file actions
executable file
·45 lines (39 loc) · 1.13 KB
/
Copy pathprompt
File metadata and controls
executable file
·45 lines (39 loc) · 1.13 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
38
39
40
41
42
43
44
45
# shellcheck shell=bash
# -*- mode: sh; -*-
# vi: set ft=sh :
green='\e[0;32m'
yellow='\e[0;33m'
blue='\e[0;34m'
white='\e[0;37m'
b_yellow='\e[1;33m'
i_red='\e[0;91m'
i_purple='\e[0;95m'
user_style="${b_yellow}";
host_style="${b_yellow}";
_vcprompt_hash() {
if git-in-repo >/dev/null 2>&1; then
git rev-parse --short=0 HEAD
fi
}
_print_if_vcs() {
if git-in-repo >/dev/null 2>&1; then
echo "$1"
fi
}
_git_stats() {
local _diffs _untracked
if git-in-repo >/dev/null 2>&1; then
_diffs=$(git status --porcelain 2>/dev/null | $GREPPAGE "M" | gwc -l)
_untracked=$(git status --porcelain 2>/dev/null | $GREPPAGE "\?\?" | gwc -l)
if [[ $_diffs != 0 ]] || [[ $_untracked != 0 ]]; then
printf ' -> %s:%s' "$_diffs" "$_untracked"
fi
fi
}
PS1="\[${user_style}\]\u\[${blue}\]@\[${host_style}\]\h"; # User and host
PS1+="\[${blue}\](\[${yellow}\]\w\[${blue}\])"; # Current working directory
PS1+="\[${green}\]\$(vcprompt -f ' %b')";
PS1+="\[${white}\]\$(_print_if_vcs '|')";
PS1+="\[${i_red}\]\$(_vcprompt_hash)";
PS1+="\[${white}\]\$(_git_stats)";
PS1+="\n\[${i_purple}\]\$\[${white}\] "; # Dollar prompt and command