aboutsummaryrefslogtreecommitdiff
path: root/bash/.bash_prompt
diff options
context:
space:
mode:
Diffstat (limited to 'bash/.bash_prompt')
-rwxr-xr-xbash/.bash_prompt52
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 @@
1red="\e[31m"
2grn="\e[32m"
3ylw="\e[33m"
4cyn="\e[36m"
5blu="\e[34m"
6prp="\e[35m"
7bprp="\e[35;1m"
8gry="\e[94m"
9rst="\e[0m"
10
11git_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
25prompt_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
36rootornot() {
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
44host() {
45 if [ "$HOSTNAME" == "localhost" ]; then
46 echo -ne "(phone)"
47 fi
48}
49
50PS1='\n$(pista)'
51
52PS2=" > "