Closed utterances-bot closed 3 years ago
Working alternative for zsh:
# ~/.zshrc
setopt PROMPT_SUBST
get_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ :\1/'
}
export PS1='%n@[%~$(get_git_branch)] $ '
https://superuser.com/questions/142099/get-function-into-ps1-zsh https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html#Prompt-Expansion
Adding colors:
export PS1='\[\033[01;32m\]\u@\[\033[00m\][\[\033[01;34m\]\w\[\033[01;31m\]$(get_git_branch)\[\033[00m\]] $ '
Command prompt setup
Quite for some time I was taking command prompt for granted, thinking that it is just as it is. But today is the day, I’m setting up the command prompt that I like!
https://sergey-melnychuk.github.io/2018/06/03/command-prompt-setup/