blob: eaeecb6344aeeae847d4c23aba43e01a80184542 (
plain)
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
|
red="\e[31m"
grn="\e[32m"
ylw="\e[33m"
cyn="\e[36m"
blu="\e[34m"
prp="\e[35m"
bprp="\e[35;1m"
gry="\e[94m"
rst="\e[0m"
git_branch() {
local git_status="$(git status 2> /dev/null)"
local on_branch="On branch ([^${IFS}]*)"
local on_commit="HEAD detached at ([^${IFS}]*)"
if [[ $git_status =~ $on_branch ]]; then
local branch=${BASH_REMATCH[1]}
echo -ne "\001${cyn}\002$branch\001${rst}\002"
elif [[ $git_status =~ $on_commit ]]; then
local commit=${BASH_REMATCH[1]}
echo -ne "\001${prp}\002$commit\001${rst}\002"
fi
}
prompt_pwd() {
if [ "$PWD" == "$HOME" ]; then
echo ""
elif [ "$PWD" == "/" ]; then
echo "/"
else
path="$(echo $PWD | sed -e "s-$HOME/--g")"
echo -ne "\001${gry}\002$path/\001${rst}\002"
fi
}
rootornot() {
if [[ "$(id -u)" -eq 0 ]]; then
echo -ne "\001${red}\002#\001${rst}\002"
else
echo -ne "λ"
fi
}
host() {
if [ "$HOSTNAME" == "localhost" ]; then
echo -ne "(phone)"
fi
}
in_nix() {
if [ "$IN_NIX_SHELL" == "impure" ]; then
echo -ne "\001${red}\002(nix)\001${rst}\002"
elif [ "$IN_NIX_SHELL" == "pure" ]; then
echo -ne "\001${grn}\002(nix)\001${rst}\002"
else
echo -ne ""
fi
}
# export PS1='\n$(prompt_pwd) $(git_branch)\n$(rootornot) '
export PS1='\n$(pista)'
export PS2=" > "
|