Last active
June 19, 2024 12:46
-
-
Save 4x8Matrix/5a8b931959bab3a8c38ba7d7b47854a4 to your computer and use it in GitHub Desktop.
bash-prompt
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
| function _setprompt { | |
| local NOCOLOR="\[\033[0m\]" | |
| local INFO_COLOR='\[\033[1;34m\]' | |
| local PROMPT_COLOR='\[\033[1;32m\]' | |
| function _parse_git_branch() { | |
| if [ -n "$(git rev-parse --git-dir 2> /dev/null)" ]; then | |
| if [ "$(git rev-list --count --all)" != "0" ]; then | |
| echo -e "-[${INFO_COLOR}$(git rev-parse --abbrev-ref HEAD)${PROMPT_COLOR}]" | |
| else | |
| echo -e "-[${INFO_COLOR}Unknown${PROMPT_COLOR}]" | |
| fi | |
| fi | |
| } | |
| PS1="${PROMPT_COLOR}┌──(${INFO_COLOR}\u@\h${PROMPT_COLOR})$(_parse_git_branch)${PROMPT_COLOR}-[${INFO_COLOR}\w${PROMPT_COLOR}]\n└─${INFO_COLOR}$ " | |
| PS2="${DARKGRAY}>${NOCOLOR} " | |
| PS3="Number: " | |
| PS4="${DARKGRAY}+${NOCOLOR} " | |
| } | |
| export PROMPT_COMMAND='_setprompt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment