diff options
author | Case Duckworth | 2022-03-13 05:36:45 +0000 |
---|---|---|
committer | Case Duckworth | 2022-03-13 05:36:45 +0000 |
commit | 7f435c1a60ddcdbd5459c04aace1bd021610660e (patch) | |
tree | 0d38931f4bee92b993d308c1dd2d7ec6acaae725 | |
parent | Accomodate more types of completion setups (diff) | |
download | etc-7f435c1a60ddcdbd5459c04aace1bd021610660e.tar.gz etc-7f435c1a60ddcdbd5459c04aace1bd021610660e.zip |
Change prompt
-rw-r--r-- | bash/prompt.bash | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/bash/prompt.bash b/bash/prompt.bash index df30c82..02d9c98 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash | |||
@@ -4,22 +4,25 @@ PS1= | |||
4 | 4 | ||
5 | # user, host, and cwd | 5 | # user, host, and cwd |
6 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') | 6 | PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') |
7 | PS1+='\[\e[36m\]\u@\h \w' | 7 | PS1+='\[\e[34m\]# \u@\h \w' |
8 | 8 | ||
9 | # git bit | 9 | # git bit |
10 | # see https://unix.stackexchange.com/questions/278206 | 10 | # see https://unix.stackexchange.com/questions/278206 |
11 | possible_git_prompt_locations=( | 11 | possible_git_prompt_locations=( |
12 | /usr/share/git/git-prompt.sh # Arch, etc. (default?) | 12 | /usr/share/git/git-prompt.sh # Arch, etc. (default?) |
13 | /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... | 13 | /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... |
14 | /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? | 14 | /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? |
15 | # I have yet to find Alpine's git prompt location. | ||
15 | ) | 16 | ) |
16 | 17 | ||
17 | for file in "${possible_git_prompt_locations[@]}"; do | 18 | for file in "${possible_git_prompt_locations[@]}"; do |
18 | if [[ -f "$file" ]]; then | 19 | if [[ -f "$file" ]]; then |
19 | source "$file" && | 20 | source "$file" && |
20 | PS1+='\[\e[35m\]$(__git_ps1)' | 21 | PS1+='\[\e[35m\]$(__git_ps1)' |
21 | break | 22 | break |
22 | fi | 23 | else |
24 | true | ||
25 | fi | ||
23 | done | 26 | done |
24 | 27 | ||
25 | # newline | 28 | # newline |
@@ -27,9 +30,9 @@ PS1+='\[\e[0m\]\n' | |||
27 | 30 | ||
28 | # exit code (only if error) | 31 | # exit code (only if error) |
29 | __prompt_exit_code() { | 32 | __prompt_exit_code() { |
30 | local ec=$? | 33 | local ec=$? |
31 | (( $ec > 0 )) && | 34 | (( $ec > 0 )) && |
32 | printf "$ec" | 35 | printf "$ec" |
33 | } | 36 | } |
34 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' | 37 | PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' |
35 | 38 | ||