Skip to content

Instantly share code, notes, and snippets.

@rodush
Last active March 30, 2023 07:18
Show Gist options
  • Select an option

  • Save rodush/30e6c53d464965c7d890e28bb289d12f to your computer and use it in GitHub Desktop.

Select an option

Save rodush/30e6c53d464965c7d890e28bb289d12f to your computer and use it in GitHub Desktop.

Revisions

  1. rodush renamed this gist Jan 5, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rodush revised this gist Jan 5, 2020. No changes.
  3. rodush created this gist Jan 5, 2020.
    18 changes: 18 additions & 0 deletions n + zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # Put this somewhere in the ~/.zshrc file

    load-nvmrc() {
    local nvmrc_path="$(pwd -P)/.nvmrc"

    if [[ -a "$nvmrc_path" ]]; then
    local nvmrc_node_version=$(cat "${nvmrc_path}")

    if [ "$nvmrc_node_version" = "N/A" ]; then
    n latest
    elif [ "$nvmrc_node_version" != "$current_node_version" ]; then
    n $nvmrc_node_version
    fi
    fi
    }

    add-zsh-hook chpwd load-nvmrc
    load-nvmrc