-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_prompt
28 lines (25 loc) · 1.05 KB
/
.bash_prompt
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
# BASED:
# * https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
# * https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt
# * https://github.com/PeterCrozier/dot-files/blob/master/.bash_profile
# * https://github.com/ryanoasis/public-bash-scripts/blob/master/unix-color-codes.sh
# * https://unix.stackexchange.com/questions/269077/tput-setaf-color-table-how-to-determine-color-codes
# Return the current git branch, if any
# Must be exported as it is used in PS1.
function GetGitBranch
{
ref=$(git symbolic-ref HEAD 2>/dev/null) || return
echo " ["${ref#refs/heads/}"]"
}
export -f GetGitBranch
# console escape sequences must be included in \[ and \] to avoid moving the cursor
RED="\[$(tput setaf 1)\]"
BRED="\[$(tput setaf 9)\]"
LRED="\[\033[01;31m\]"
GRN="\[$(tput setaf 2)\]"
LGRN="\[\033[01;32m\]"
BLU="\[$(tput setaf 4)\]"
LBLU="\[\033[01;34m\]"
RST="\[$(tput sgr0)\]"
export PS1="$LGRN\u@\h:$LBLU\w$RED\$(GetGitBranch) $BLU\$(date +%Y/%m/%d-%H:%M:%S)$RST\n $ "
export SUDO_PS1="$RED\w $BLU\u$RST # "