-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash_prompt
More file actions
30 lines (26 loc) · 1.18 KB
/
bash_prompt
File metadata and controls
30 lines (26 loc) · 1.18 KB
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
#!/usr/bin/env bash
## usefull strings to compose ps1
PRE_PS1=$PRE_PS1 # here you can prepend functions
PS_USER=${PS_USER-'\u'}
PS_SEPARATOR=${PS_SEPARATOR-'@'}
PS_HOST=${PS_HOST-'\h'}
PS_PATH=${PS_PATH-'\w'}
POST_PS1=$POST_PS1 # append functions in ps1
PS_CARET=${PS_CARET-'❯'} # thanks @sindresorhus to find it!
# Assume it's compliant with Ecma-48 (ISO/IEC-6429). (Lack of such support is
# extremely rare, and such a case would tend to support setf rather than setaf.)
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
[[ $EUID -ne 0 ]] && cu='150m' || cu='202m'
PS_USER='\[\e[38;5;'$cu'\]'$PS_USER'\[\e[00m\]'
PS_SEPARATOR='\[\e[38;5;101m\]'$PS_SEPARATOR'\[\e[00m\]'
PS_HOST='\[\e[38;5;148m\]'$PS_HOST'\[\e[00m\]'
PS_PATH='\[\e[00;36m\]'$PS_PATH'\[\e[00m\]'
PS_CARET='\[\e[38;5;105m\]'$PS_CARET'\[\e[00m\]'
fi
# Hide the default user (who host the files)
dir="$(cd "$(dirname -- "$0")" && pwd)"
#[[ "$(echo "$dir" | grep -o $USER)" != "" ]] && PS_USER=''
# disable machine information unless you're sshing it.
[[ -z $SSH_CONNECTION ]] && PS_SEPARATOR='' && PS_HOST=''
PS1=${PS1_TEMPLATE-"\n$PRE_PS1$PS_USER$PS_SEPARATOR$PS_HOST $PS_PATH$POST_PS1\n$PS_CARET "}
PS2="$PS_CARET "