Last active
September 20, 2025 14:46
-
-
Save walteh/663b6b396151e0ab9f7e8daf43a8f9bf to your computer and use it in GitHub Desktop.
bash_prompt_simple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __bash_prompt_simple() { | |
| local e=$? p a o i ee faint=$'\e[2m' err=$'\e[31m' esc=$'\e[0m' bold=$'\e[1m' op='\[' cl='\]' | |
| [[ $PWD == "$HOME"* ]] && p="~${PWD#$HOME}" || p=$PWD | |
| IFS=/ read -ra a<<<"$p"; o=${a[0]} | |
| for((i=1;i<${#a[@]}-1;i++)); do [[ ${a[i]} ]] && o+="$op$faint$cl/$op$esc$cl${a[i]:0:1}"; done | |
| [[ ${#a[@]} -gt 1 ]] && o+="$op$faint$cl/$op$esc$cl$op$bold$cl${a[-1]}$op$esc$cl" | |
| [[ $e != 0 ]] && ee=" $op$err$cl$e$op$esc$cl" || ee="" | |
| PS1="$o$ee $op$faint$cl\$$op$esc$cl " | |
| }; | |
| PROMPT_COMMAND=__bash_prompt_simple |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
basically only does two things: