From 67a70e6dc23a9b3881dbb9cffcf641e52a6acfcc Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Sat, 15 Nov 2014 22:43:17 +0100 Subject: [PATCH] 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) --- install.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/install.sh b/install.sh index 8974593..6a00f75 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,15 @@ #!/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 nvm_has() { @@ -135,6 +145,24 @@ nvm_do_install() { 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" nvm_reset }