Skip to content

Commit

Permalink
Add support for fish shell
Browse files Browse the repository at this point in the history
This commit also:

- Set NODE_PATH with `npm root -g`.
- Removes call to `manpath`. This script should not be responsible for
  loading OS manual pages.
  • Loading branch information
psqli committed Dec 18, 2021
1 parent 1a4af40 commit d9cdfb4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions npm-g-nosudo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ if [ -s $to_reinstall ]; then
fi

envfix='
# exports for Node.js (generated by npm-g-nosudo.sh)
export NPM_PACKAGES="%s"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
export MANPATH="$NPM_PACKAGES/share/man:$MANPATH"
export NODE_PATH="$(npm root -g)"
'

envfix_fish='
# exports for Node.js (generated by npm-g-nosudo.sh)
set -gx NPM_PACKAGES "%s"
fish_add_path $NPM_PACKAGES/bin
set -gx MANPATH $NPM_PACKAGES/share/man $MANPATH
set -gx NODE_PATH (npm root -g)
'

fix_env() {
Expand All @@ -139,12 +145,17 @@ fix_env() {
printf "${envfix}" ${npmdir} >> ~/.zshrc
printf "\nDon't forget to run 'source ~/.zshrc'\n"
fi

if [ -d "${HOME}/.config/fish/conf.d" ]; then
printf "${envfix_fish}" ${npmdir} >> ~/.config/fish/conf.d/nodejs_path_setup.fish
printf "\nDon't forget to run 'source ~/.config/fish/conf.d/nodejs_path_setup.fish'\n"
fi
}

echo_env() {
printf "\nYou may need to add the following to your ~/.bashrc / .zshrc file(s)\n\n"
printf "${envfix}\n\n" ${npmdir}
printf "\nOr the following to your ~/.config/fish/config.fish file\n\n"
printf "${envfix_fish}\n\n" ${npmdir}
}

printf "\n\n"
Expand Down

0 comments on commit d9cdfb4

Please sign in to comment.