Created
January 27, 2020 09:36
-
-
Save xelaz/09b1ddfb052485faa12dd628470262ec to your computer and use it in GitHub Desktop.
Zsh prompt with git branch, current node version and .nvmrc version
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
##### PS1 ####### | |
autoload -U colors && colors | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
check_node() { | |
diff <(node -v 2> /dev/null) <(cat .nvmrc 2> /dev/null)| sed -e "/^[^>*]/d" -e 's/>.* \(.*\)/ (\1)/' | |
} | |
current_node() { | |
node -v 2> /dev/null | sed 's/\(.*\)/ (\1)/' | |
} | |
setopt PROMPT_SUBST | |
PROMPT='%F{red}%n%f@%F{yellow}%m%f:%F{82}%d%f%F{33}$(parse_git_branch)%f%F{159}$(current_node)%f%F{197}$(check_node)%f | |
%F{27}%#%f ' | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxCxDxBxegedabagacad | |
################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
user@host:cwd (branch) (current nvm version) (needed nvm version if it's not equal with current)