-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
'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.
Manipulating
See https://fishshell.com/docs/current/tutorial.html#tut_path (note: |
Yes and no. While it is supported, I have come across many problems with the
|
Trying to use the PATH as an universal variable isn't supported by fish. However, setting the fish_user_paths works just fine. Note that this should only be run once on installation since universal variables are saved across sessions. This is also why you shouldn't have setup in config.fish if you can avoid it. I use fish_user_paths, and have for a few years now, and haven't had any problems, but I guess your milage may vary. |
As @ridiculousfish suggests, the The problem I see here is that the install script is run in bash. If we run the command Thoughts? |
Maybe |
Note that adding |
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.
@maxnordlund, @hildjj check the new commit. Let me know what you think. |
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I like it, but see my comment above. |
@maxnordlund, done and works. Thank you 👍 |
Kein problem, just happy to help 😸 |
I made #766 for fixing the escape codes, after that the |
@maxnordlund looks good. We need to hear from the maintainers on this one. Once your PR gets through, I can add the (~/.yarn/bin/yarn global bin) part too. |
thank you! I think this is reasonable to support. cc @kittens |
@cpojer Yay! Thank you. |
Summary
This PR adds support for handling installation of
yarn
on fish shell.fish is a popular shell. Me and many I know use it regularly for its awesome auto-completion features and convenience.
The current problem is that the
yarn
install script only checks for bash and zsh shells. This was causing~/.yarn/bin
to not be added to the$PATH
in fish.With this commit, the
yarn
install script first checks if the user's shell is fish. If so, it adds the following line to~/.config/fish/config.fish
.See Startup (Where's .bashrc?) section in official fish documentation for more information.
Test plan
When
yarn/scripts/install_latest.sh
is run, following happens:After successful installation, my
~/.config/fish/config.fish
looks like this: