Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourcing .zshrc is changing nvm node version to system node ignoring set defaults #1703

Closed
JonahMoses opened this issue Jan 8, 2018 · 10 comments
Labels
needs followup We need some info or action from whoever filed this issue/PR. shell: zsh: oh-my-zsh

Comments

@JonahMoses
Copy link

screen shot 2018-01-08 at 12 07 11 am

I do not have a .npmrc and the following lines are in my .zshrc file:
export PATH="~/.yarn/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

@ljharb
Copy link
Member

ljharb commented Jan 8, 2018

Can you share the rest of your .zshrc?

@JonahMoses
Copy link
Author

JonahMoses commented Jan 8, 2018

```sh export PATH="~/.yarn/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

Would you like to use another custom folder than $ZSH/custom?

ZSH_CUSTOM=~/.dotfiles/custom

See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

ZSH_THEME="TheOne"

plugins=()

export ZSH=/Users/jonahmoses/.oh-my-zsh
source $ZSH/oh-my-zsh.sh

show contents of directory after cd-ing into it

chpwd() { l }

Colors

autoload -U colors
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
colors

Use vim as the visual editor

export VISUAL=vim
export EDITOR=vim

Save a ton of history

setopt hist_ignore_all_dups inc_append_history
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=5000

FZF & RipGrep

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --glob "!{.git,node_modules}/*" 2> /dev/null'

fpath=(/usr/local/share/zsh-completions $fpath)

source ~/.dotfiles/aliases.zsh
source ~/.dotfiles/prompt.zsh

source nvm

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

</details>

@ljharb
Copy link
Member

ljharb commented Jan 8, 2018

Thanks - what about aliases.zsh and prompt.zsh?

@ljharb ljharb added needs followup We need some info or action from whoever filed this issue/PR. shell: zsh: oh-my-zsh labels Jan 8, 2018
@JonahMoses
Copy link
Author

JonahMoses commented Jan 8, 2018

prompt.zsh

```sh setopt prompt_subst

autoload -Uz vcs_info

zstyle ':vcs_info:' enable git
zstyle ':vcs_info:
' stagedstr 'M'
zstyle ':vcs_info:' unstagedstr 'M'
zstyle ':vcs_info:
' check-for-changes true
zstyle ':vcs_info:' actionformats '%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:
' formats
'%F{5}[%F{2}%b%F{5}] %F{2}%c%F{3}%u%f'
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] &&
git status --porcelain | grep '??' &> /dev/null ; then
hook_com[unstaged]+='%F{1}??%f'
fi
}

precmd () { vcs_info }
PROMPT='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_} %fॐ '

</details>

@JonahMoses
Copy link
Author

JonahMoses commented Jan 8, 2018

aliases.zsh

```sh # Other alias v='vim' alias vi='vim' alias be='bundle exec' alias bu='bundle update' alias bi='bundle install' alias reload='source ~/.dotfiles/.zshrc' alias sane='stty sane' alias ll='ls -al'

Movement

alias ..='cd ..'
alias ~='cd ~'
alias .f='cd ~/.dotfiles'
alias vrc='vim ~/.vimrc'
alias zrc='vim ~/.zshrc'
alias trc='vim ~/.tmux.conf'
alias aliases='vim ~/.dotfiles/aliases.zsh'
alias plugins='vim ~/.dotfiles/.vim/plugins.vim'
alias coding='cd ~/coding'

#RipGrep
alias rg='rg --ignore-case --no-heading'

Git

alias gh="git log --pretty=format:'%h - %ad (%ar) - [%an] : %s' --date=short --graph --since=5.months"
alias gs='git status'
alias g='git'
alias gb='git branch'
alias push='git push'
alias pull='git fetch && git pull'
alias ga='git add -A :/'
alias gbx='git branch -D'
alias gbc='git checkout -b'
alias gco='git checkout'
alias master='git checkout master'
alias gca='git commit --amend'
alias diff='git diff | gitx'
gcm() { git commit -m "$*" }

Tmux

alias tns='tmux new -s'
alias tat='tmux attach -t'
alias tls='tmux list-sessions'
alias tks='tmux kill-session -t'

Spelling

alias zues='zeus'
alias alaises='aliases'

</details>

@ljharb
Copy link
Member

ljharb commented Jan 8, 2018

hmm, nothing strange there :-/

If from bash, you do nvm deactivate before sourcing .zshrc, what happens?

@JonahMoses
Copy link
Author

My default shell is zsh so I'm never in bash land. However if I switch to bash with exec bash then nvm deactivate I get a nvm command not found

@ljharb
Copy link
Member

ljharb commented Jan 8, 2018

ok, so then in zsh prior to sourcing zshrc, if you do nvm deactivate, and then source zshrc :-)

@JonahMoses
Copy link
Author

Either that or adding PATH="/usr/local/bin:$(getconf PATH)" to the top of my .zshrc file seemed to fix it

@tflx
Copy link

tflx commented Jan 9, 2018

Thank you!...The PATH thing fixed it for me. Been struggling with this.

@ljharb ljharb closed this as completed Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR. shell: zsh: oh-my-zsh
Projects
None yet
Development

No branches or pull requests

3 participants