Skip to content

Instantly share code, notes, and snippets.

@mikehazell
Last active August 5, 2024 15:31
Show Gist options
  • Save mikehazell/e2d4d77575ace164e636ec2347a24697 to your computer and use it in GitHub Desktop.
Save mikehazell/e2d4d77575ace164e636ec2347a24697 to your computer and use it in GitHub Desktop.
oh-my-zsh Default Theme plus Node version info
# oh-my-zsh Theme
# Default robbyrussell theme with node version info.
# Installation: place this file in .oh-my-zsh/custom/themes/robbyrussell.zsh_theme
function node_prompt_version {
if which node &> /dev/null; then
echo "%{$fg_bold[blue]%}node(%{$fg[red]%}$(node -v)%{$fg[blue]%}) %{$reset_color%}"
fi
}
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(node_prompt_version)$(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@magnafilix
Copy link

thanks, it works!

@huangyingjie
Copy link

thanks, help me a lot. echo transfer to echo -n

@jsguillerme
Copy link

I defined a local variable for node_prompt_version result (local node_version='$(node_prompt_version)'), now I can switch node using nvm with correct node version on prompt.

thanks, nice idea!

@rizqikazukun
Copy link

rizqikazukun commented Aug 5, 2024

Cool thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment