mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 17:41:50 +00:00
Include actions for fish when installing
Fish has to be configured to use nvm. Basically 2 actions have to be taken (like with bash and others): 1. Introduce the nvm function 2. Execute the nvm function once the shell is loaded to have access to nodejs The first session with fish might take a while to start, if nvm doesn't have its default env (stable nodejs + default alias)
This commit is contained in:
parent
1eac915fba
commit
67a70e6dc2
28
install.sh
28
install.sh
@ -1,5 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get this script after dereferincing all symlinks
|
||||||
|
# !! Doesn't check for circular symlinks !!
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
SOURCE="$(readlink "$SOURCE")"
|
||||||
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
|
done
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
nvm_has() {
|
nvm_has() {
|
||||||
@ -135,6 +145,24 @@ nvm_do_install() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Actions for fish shell
|
||||||
|
if (which fish > /dev/null); then
|
||||||
|
echo "=> fish found, copying nvm function"
|
||||||
|
FISH_CONFIG_DIR=$HOME/.config/fish
|
||||||
|
FISH_FUNCTIONS_DIR=$FISH_CONFIG_DIR/functions
|
||||||
|
|
||||||
|
mkdir -p $FISH_FUNCTIONS_DIR
|
||||||
|
cp $NVM_DIR/nvm.fish $FISH_FUNCTIONS_DIR
|
||||||
|
|
||||||
|
# Apply nvm in fish configuration
|
||||||
|
FISH_CONFIG_STRING="nvm > /dev/null ^&1"
|
||||||
|
FISH_CONFIG_FILE=$FISH_CONFIG_DIR/config.fish
|
||||||
|
if ! grep -q "$FISH_CONFIG_STRING" $FISH_CONFIG_FILE 2> /dev/null ; then
|
||||||
|
echo "=> appending nvm to fish configuration"
|
||||||
|
echo $FISH_CONFIG_STRING >> $FISH_CONFIG_DIR/config.fish
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=> Close and reopen your terminal to start using nvm"
|
echo "=> Close and reopen your terminal to start using nvm"
|
||||||
nvm_reset
|
nvm_reset
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user