Custom Bash Prompt
August 20, 2023•59 words
Prompt
function set_ps1 {
export PS1="\n\033[4m\u@\h:\w $(git branch 2>/dev/null | grep '*')\033[0m\n$ "
}
export PROMPT_COMMAND=set_ps1
Meanings of tokens of the prompt above:
- \n — New line
- \033[4m — Start of underline
- \033[0m — End of underline
- \u — Username
- \h — Host name
- \w — Working directory (full path)