about summary refs log tree commit diff stats
path: root/bash/prompt.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/prompt.bash')
-rw-r--r--bash/prompt.bash25
1 files changed, 16 insertions, 9 deletions
diff --git a/bash/prompt.bash b/bash/prompt.bash index f09d3ab..bee5223 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash
@@ -26,13 +26,7 @@ __prompt_exit_code() { # __prompt_exit_code CODES...
26 printf '%s\n' "$ec" 26 printf '%s\n' "$ec"
27} 27}
28 28
29two_line_prompt() { 29git_prompt_integration() {
30 PS1=
31
32 # user, host, and cwd
33 PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
34 PS1+='\[\e[0;46m\]\u@\h \w'
35
36 # git bit 30 # git bit
37 # see https://unix.stackexchange.com/questions/278206 31 # see https://unix.stackexchange.com/questions/278206
38 possible_git_prompt_locations=( 32 possible_git_prompt_locations=(
@@ -45,10 +39,18 @@ two_line_prompt() {
45 for file in "${possible_git_prompt_locations[@]}"; do 39 for file in "${possible_git_prompt_locations[@]}"; do
46 if [[ -f "$file" ]]; then 40 if [[ -f "$file" ]]; then
47 source "$file" && 41 source "$file" &&
48 PS1+='\[\e[0m\]\[\e[35m\]$(__git_ps1)' 42 PS1+='\[\e[35m\]$(__git_ps1) \[\e[0m\]'
49 break 43 break
50 fi 44 fi
51 done 45 done
46}
47
48two_line_prompt() {
49 PS1=
50
51 # user, host, and cwd
52 PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...')
53 PS1+='\[\e[0;46m\]\u@\h \w'
52 54
53 # newline 55 # newline
54 PS1+='\[\e[0m\]\n' 56 PS1+='\[\e[0m\]\n'
@@ -62,7 +64,12 @@ two_line_prompt() {
62 64
63smiley_prompt() { 65smiley_prompt() {
64 __prompt_ec() { case $? in 0) echo '^_^' ;; *) echo ';_;' ;; esac } 66 __prompt_ec() { case $? in 0) echo '^_^' ;; *) echo ';_;' ;; esac }
65 PS1='\[\e[1m\]$(__prompt_exit_code "ok=^_^" "fail=;_;") \w\[\e[0m\] ' 67
68 PS1='\[\e[33m\]$(__prompt_exit_code "ok=^_^" "fail=;_;")'
69 PS1+=' \w\[\e[0m\]'
70
71 git_prompt_integration
72
66 PS1+='\[$(__prompt_term_title "$USER@$(hostname): $PWD")\]' 73 PS1+='\[$(__prompt_term_title "$USER@$(hostname): $PWD")\]'
67 PS1+='\$ ' 74 PS1+='\$ '
68} 75}