Skip to content

Commit

Permalink
Handle installation for 'fish' shell (yarnpkg#690)
Browse files Browse the repository at this point in the history
* Handle installation for 'fish' shell

'fish' is a popular shell. This commit adds support for proper detection and installation of yarn in 'fish' shell. If the detected shell is 'fish', add path to ~/.yarn/bin in $HOME/.config/fish/config.fish file.

* Use a more modern way of setting $PATH in fish

Set `~/.yarn/bin` in `$fish_user_paths` instead of setting it in `~/.config/fish/config.fish` file.

See [suggestion from fish documentation](fish-shell/fish-shell#527 (comment)) for more reference.

* Run command to set $fish_user_paths instead of evaluating a string.
  • Loading branch information
hasit authored and cpojer committed Oct 12, 2016
1 parent c9415ca commit 16b4e3b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/install-latest.sh
Expand Up @@ -31,7 +31,11 @@ yarn_link() {
command printf "${SOURCE_STR}"
else
if ! grep -q 'yarn' "$YARN_PROFILE"; then
command printf "$SOURCE_STR" >> "$YARN_PROFILE"
if [[ $YARN_PROFILE == *"fish"* ]]; then
command fish -c 'set -U fish_user_paths $fish_user_paths ~/.yarn/bin'
else
command printf "$SOURCE_STR" >> "$YARN_PROFILE"
fi
fi

printf "$cyan> We've added the following to your $YARN_PROFILE\n"
Expand Down Expand Up @@ -61,6 +65,8 @@ yarn_detect_profile() {
fi
elif [ "$SHELLTYPE" = "zsh" ]; then
DETECTED_PROFILE="$HOME/.zshrc"
elif [ "$SHELLTYPE" = "fish" ]; then
DETECTED_PROFILE="$HOME/.config/fish/config.fish"
fi

if [ -z "$DETECTED_PROFILE" ]; then
Expand All @@ -72,6 +78,8 @@ yarn_detect_profile() {
DETECTED_PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
DETECTED_PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.config/fish/config.fish" ]; then
DETECTED_PROFILE="$HOME/.config/fish/config.fish"
fi
fi

Expand Down

0 comments on commit 16b4e3b

Please sign in to comment.