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

Add support for fish shell #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions npm-g-nosudo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fi

if [ 0 = ${DEBUG} ]; then
mkdir -p ${npmdir}
mkdir ${npmdir}/bin
npm config set prefix $npmdir
fi

Expand All @@ -121,13 +122,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 +146,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