diff options
Diffstat (limited to 'bash/.bash_prompt')
-rwxr-xr-x | bash/.bash_prompt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bash/.bash_prompt b/bash/.bash_prompt new file mode 100755 index 0000000..667d32a --- /dev/null +++ b/bash/.bash_prompt | |||
@@ -0,0 +1,52 @@ | |||
1 | red="\e[31m" | ||
2 | grn="\e[32m" | ||
3 | ylw="\e[33m" | ||
4 | cyn="\e[36m" | ||
5 | blu="\e[34m" | ||
6 | prp="\e[35m" | ||
7 | bprp="\e[35;1m" | ||
8 | gry="\e[94m" | ||
9 | rst="\e[0m" | ||
10 | |||
11 | git_branch() { | ||
12 | local git_status="$(git status 2> /dev/null)" | ||
13 | local on_branch="On branch ([^${IFS}]*)" | ||
14 | local on_commit="HEAD detached at ([^${IFS}]*)" | ||
15 | |||
16 | if [[ $git_status =~ $on_branch ]]; then | ||
17 | local branch=${BASH_REMATCH[1]} | ||
18 | echo -ne "\001${cyn}\002 $branch\001${rst}\002" | ||
19 | elif [[ $git_status =~ $on_commit ]]; then | ||
20 | local commit=${BASH_REMATCH[1]} | ||
21 | echo -ne "\001${prp}\002 $commit\001${rst}\002" | ||
22 | fi | ||
23 | } | ||
24 | |||
25 | prompt_pwd() { | ||
26 | if [ "$PWD" == "$HOME" ]; then | ||
27 | echo "" | ||
28 | elif [ "$PWD" == "/" ]; then | ||
29 | echo "/" | ||
30 | else | ||
31 | path="$(echo $PWD | sed -e "s-$HOME/--g")" | ||
32 | echo -ne " \001${gry}\002$path/\001${rst}\002" | ||
33 | fi | ||
34 | } | ||
35 | |||
36 | rootornot() { | ||
37 | if [[ "$(id -u)" -eq 0 ]]; then | ||
38 | echo -ne "\001${red}\002#\001${rst}\002" | ||
39 | else | ||
40 | echo -ne "$" | ||
41 | fi | ||
42 | } | ||
43 | |||
44 | host() { | ||
45 | if [ "$HOSTNAME" == "localhost" ]; then | ||
46 | echo -ne "(phone)" | ||
47 | fi | ||
48 | } | ||
49 | |||
50 | PS1='\n$(pista)' | ||
51 | |||
52 | PS2=" > " | ||