################################################################################ # ------------------------- # BASH PROMPT CONFIGURATION # ------------------------- # Description: # Shows a nicer bash prompt: # ▶ 🖳 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ # -------- --------- ---------- --- ----- # | | | | | # hostname folder git branch jobs last command result # # See https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514#file-prompt_demo-png # for a colurful demo. # # Last version of this file can be found at # https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514 # # Usage: # 1. Get a copy of __git_ps1 # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh # 2. Copy this file in your local diretory as ~/.bash_prompt # 3. Edit your ~/.bashrc and add this line: # . ~/.bash_prompt # 4. Reload your ~/.bashrc: # . ~/.bashrc # # Requires: # * Some unicode font # * 256 colors support in your terminal # * __git_ps1 # # Useful info: # * http://misc.flogisoft.com/bash/tip_colors_and_formatting # * https://github.com/morhetz/gruvbox # * https://gist.github.com/MicahElliott/719710 # ################################################################################ ####################### # Git config ####################### # Need to get git-prompt: # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh if [ -f ~/.git-prompt.sh ]; then . ~/.git-prompt.sh fi GIT_PS1_SHOWDIRTYSTATE="" GIT_PS1_SHOWCOLORHINTS="" GIT_PS1_SHOWUNTRACKEDFILES="" GIT_PS1_SHOWUPSTREAM="" GIT_PS1_SHOWSTASHSTATE="" ####################### # Colors ####################### # Color reset PLAIN='\e[0m' # Text colors RED='\e[31m' GREEN='\e[32m' BLUE='\e[1;38;5;25m' LIGHTGRAY='\e[1;38;5;252m' GRAY='\e[1;38;5;242m' WHITE='\e[1;38;5;251m' ORANGE='\e[1;38;5;130m' BOLDBLACK='\e[1;38;5;232m' # Background colors BGBLACK='\e[40m' BGBLUE='\e[48;5;25m' BGLIGHTGRAY='\e[48;5;252m' BGGRAY='\e[48;5;242m' ####################### # Icons (I_ICON_NAME) ####################### I_ARROW="▶" #I_HOST=" 💻 " This character casues some issues I_HOST=" 🖳 " I_GIT=" ⎇ " I_OK="✔" I_KO="✖️" ####################### # Styles (S_STYLE_NAME) ####################### S_HOST_BG=$BGLIGHTGRAY S_HOST_TXT=$BOLDBLACK S_HOST_ARROW=$GRAY S_DIR_BG=$BGGRAY S_DIR_TXT=$LIGHTGRAY S_GIT_BG=$BGBLUE S_GIT_TXT=$WHITE S_GIT_ARROW=$GRAY S_TASK_BG=$BGBLACK S_TASK_TXT=$ORANGE S_TASK_ARROW=$BLUE S_RESULT_OK=$GREEN S_RESULT_KO=$RED ####################### # Prompt parts (P_*) ####################### P_HOST=`printf "\[$S_HOST_BG\]\[$S_HOST_ARROW\]$I_ARROW\[$S_HOST_TXT\] $I_HOST\h "` P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "` P_GIT=' P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\` if [ -z $P_GIT_BRANCH ]; then printf " \[$S_TASK_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; else printf " \[$S_GIT_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; fi ' # Number of jobs running P_JOBS=`printf " echo -n '\[$S_TASK_TXT\]' case '\j' in 0) echo -n '';; 1) echo -n '𝍠 ' ;; 2) echo -n '𝍡 ' ;; 3) echo -n '𝍢 ' ;; 4) echo -n '𝍣 ' ;; *) echo -n '𝍤 ' ;; esac echo -n '\[$PLAIN\]' "` # Result of the last command P_CMD_RESULT=" if [ \$LASTCMD -eq 0 ]; then echo -n \[$S_RESULT_OK\]$I_OK\[$PLAIN\]; else echo -n \[$S_RESULT_KO\]$I_KO\[$PLAIN\]; fi echo -n ' ' " PROMPT_COMMAND='LASTCMD=$? PS1="${debian_chroot:+($debian_chroot)}${P_HOST}${P_DIR}\`${P_GIT}\`\`${P_JOBS}\`\`${P_CMD_RESULT}\` "'