custom nodenv plugin
This commit is contained in:
parent
27caabc1e8
commit
d36f5d5088
38
home/.zsh/custom/plugins/nodenv/nodenv.plugin.zsh
Normal file
38
home/.zsh/custom/plugins/nodenv/nodenv.plugin.zsh
Normal file
@ -0,0 +1,38 @@
|
||||
_homebrew-installed() {
|
||||
type brew &> /dev/null
|
||||
}
|
||||
|
||||
FOUND_NODENV=0
|
||||
nodenvdirs=("$HOME/.nodenv" "/usr/local/nodenv" "/opt/nodenv" "/usr/local/opt/nodenv")
|
||||
if _homebrew-installed && nodenv_homebrew_path=$(brew --prefix nodenv 2>/dev/null); then
|
||||
nodenvdirs=($nodenv_homebrew_path "${nodenvdirs[@]}")
|
||||
unset nodenv_homebrew_path
|
||||
fi
|
||||
|
||||
for nodenvdir in "${nodenvdirs[@]}" ; do
|
||||
if [ -d $nodenvdir/bin -a $FOUND_NODENV -eq 0 ] ; then
|
||||
FOUND_NODENV=1
|
||||
if [[ $NODENV_ROOT = '' ]]; then
|
||||
NODENV_ROOT=$nodenvdir
|
||||
fi
|
||||
export NODENV_ROOT
|
||||
export PATH=${nodenvdir}/bin:$PATH
|
||||
eval "$(nodenv init --no-rehash - zsh)"
|
||||
|
||||
alias nodes="nodenv versions"
|
||||
|
||||
function current_node() {
|
||||
echo "$(nodenv version-name)"
|
||||
}
|
||||
|
||||
function nodenv_prompt_info() {
|
||||
echo "$(current_node)"
|
||||
}
|
||||
fi
|
||||
done
|
||||
unset nodenvdir
|
||||
|
||||
if [ $FOUND_NODENV -eq 0 ] ; then
|
||||
alias nodes='node -v'
|
||||
function nodenv_prompt_info() { echo "system: $(node -v | tr -d 'v')" }
|
||||
fi
|
@ -5,7 +5,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
PROMPT='%{$fg[$HCOLOR]%}%m%{$reset_color%}:%c $(git_prompt_info)%{$fg[red]%}%(!.#.»)%{$reset_color%} '
|
||||
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
|
||||
RPS1='%{$fg[cyan]%}(%{$fg[red]%}$(ruby_prompt_info) %{$fg[green]%}$(nodenv version-name) %{$fg[blue]%}$(pyenv_prompt_info)%{$fg[cyan]%}) %{$reset_color%}${return_code}'
|
||||
RPS1='%{$fg[cyan]%}(%{$fg[red]%}$(ruby_prompt_info) %{$fg[green]%}$(nodenv_prompt_info) %{$fg[blue]%}$(pyenv_prompt_info)%{$fg[cyan]%}) %{$reset_color%}${return_code}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}±%{$fg[yellow]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
|
@ -26,11 +26,12 @@ plugins=($plugins ruby gem rbenv rails bundler heroku)
|
||||
export RBENV_ROOT=$HOME/.rbenv
|
||||
|
||||
# node
|
||||
plugins=($plugins npm yarn)
|
||||
eval "$(nodenv init -)"
|
||||
plugins=($plugins nodenv npm yarn)
|
||||
export NODENV_ROOT=$HOME/.nodenv
|
||||
|
||||
# python
|
||||
plugins=($plugins pyenv pip)
|
||||
export PYENV_ROOT=$HOME/.pyenv
|
||||
|
||||
# php / drupal
|
||||
plugins=($plugins drush composer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user