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

Handle installation for 'fish' shell #690

Merged
merged 3 commits into from
Oct 12, 2016
Merged
Changes from 2 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
11 changes: 10 additions & 1 deletion scripts/install-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ yarn_link() {
printf "$cyan> Adding to \$PATH...$reset\n"
YARN_PROFILE="$(yarn_detect_profile)"
SOURCE_STR="\nexport PATH=\"\$HOME/.yarn/bin:\$PATH\"\n"
FISH_SOURCE_STR="fish -c 'set -U fish_user_paths \$fish_user_paths ~/.yarn/bin'"

if [ -z "${YARN_PROFILE-}" ] ; then
printf "$red> Profile not found. Tried ${YARN_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.\n"
Expand All @@ -31,7 +32,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
eval $FISH_SOURCE_STR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's better to just run the command here instead of evaluating it?

command fish -c 'set -U fish_user_paths $fish_user_paths ~/.yarn/bin'

Since it's not appended to a file anymore.

Copy link
Contributor Author

@hasit hasit Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Saves space of storing a command string as well.

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 +66,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 +79,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