|
| 1 | +COLOR_RESET=$(echo -en '\001\033[0m\002') |
| 2 | +COLOR_RED=$(echo -en '\001\033[00;31m\002') |
| 3 | +COLOR_GREEN=$(echo -en '\001\033[00;32m\002') |
| 4 | +COLOR_YELLOW=$(echo -en '\001\033[00;33m\002') |
| 5 | +COLOR_BLUE=$(echo -en '\001\033[00;34m\002') |
| 6 | +COLOR_MAGENTA=$(echo -en '\001\033[00;35m\002') |
| 7 | +COLOR_PURPLE=$(echo -en '\001\033[00;35m\002') |
| 8 | +COLOR_CYAN=$(echo -en '\001\033[00;36m\002') |
| 9 | +COLOR_LIGHTGRAY=$(echo -en '\001\033[00;37m\002') |
| 10 | +COLOR_LRED=$(echo -en '\001\033[01;31m\002') |
| 11 | +COLOR_LGREEN=$(echo -en '\001\033[01;32m\002') |
| 12 | +COLOR_LYELLOW=$(echo -en '\001\033[01;33m\002') |
| 13 | +COLOR_LBLUE=$(echo -en '\001\033[01;34m\002') |
| 14 | +COLOR_LMAGENTA=$(echo -en '\001\033[01;35m\002') |
| 15 | +COLOR_LPURPLE=$(echo -en '\001\033[01;35m\002') |
| 16 | +COLOR_LCYAN=$(echo -en '\001\033[01;36m\002') |
| 17 | +COLOR_WHITE=$(echo -en '\001\033[01;37m\002') |
| 18 | + |
| 19 | + |
| 20 | +# Set Terminal title - current folder |
| 21 | +function userTerminalTitlePwd { |
| 22 | + echo -e '\033]2;' # open terminal title |
| 23 | + # content of the terminal window: |
| 24 | + echo -e '${HOST_DISPLAY_NAME}: \w' |
| 25 | + echo -e '\007' # close terminal title |
| 26 | +} |
| 27 | + |
| 28 | +# Render exit code |
| 29 | +function exitCodeWarning { |
| 30 | + code=$? |
| 31 | + if [[ $code != 0 ]]; then |
| 32 | + echo -e "${COLOR_RED}✗✗✗ exit code was ${code} ✗✗✗\n\n${COLOR_RESET}" |
| 33 | + fi |
| 34 | +} |
| 35 | + |
| 36 | +# Render Git branch for PS1 |
| 37 | +function renderGitBranch { |
| 38 | + if [ -f $(which git) ]; then |
| 39 | + echo "${COLOR_YELLOW}$(__git_ps1)" |
| 40 | + fi |
| 41 | +} |
| 42 | + |
| 43 | +function customPrompt { |
| 44 | + # this function is only there that it can be overwritten in with your own custom prompt |
| 45 | + true |
| 46 | +} |
| 47 | + |
| 48 | +# Style bash prompt |
| 49 | +PS1='' |
| 50 | +PS1+='\033]2;${HOST_DISPLAY_NAME}: \w\007' # terminal Title |
| 51 | +PS1+='$(exitCodeWarning)' # git information |
| 52 | +#PS1+='$(if [[ $? != 0 ]]; then echo "\n"; fi)' |
| 53 | +PS1+='${COLOR_CYAN}[' |
| 54 | + |
| 55 | +PS1+='${COLOR_LRED}\u' # user |
| 56 | +PS1+='${COLOR_CYAN}@' |
| 57 | +PS1+='${COLOR_LBLUE}${HOST_DISPLAY_NAME}' # container name |
| 58 | +PS1+='${COLOR_CYAN}: ' |
| 59 | +PS1+='${COLOR_RESET}\w' # working directory |
| 60 | + |
| 61 | +PS1+='${COLOR_CYAN}]' |
| 62 | + |
| 63 | +PS1+='$(renderGitBranch)' # git information |
| 64 | +PS1+='$(customPrompt)' # git information |
| 65 | + |
| 66 | +PS1+='${COLOR_CYAN}> ' |
| 67 | +PS1+='${COLOR_RESET} '; |
| 68 | +PS1+='\n' |
| 69 | +PS1+='\$ ' |
0 commit comments