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

Fish shell compatibility #358

Open
dmsmidt opened this issue Oct 27, 2015 · 9 comments
Open

Fish shell compatibility #358

dmsmidt opened this issue Oct 27, 2015 · 9 comments

Comments

@dmsmidt
Copy link

dmsmidt commented Oct 27, 2015

The Fish Shell (http://fishshell.com/) is used by many developers instead of Bash or ZSH.
Currently the Platform app makes some Linux System crash on startup when the platform CLI is installed and Fish is the default shell.

[RuntimeException]
Cannot generate hook for unknown shell type 'fish'. Available hooks are: bash, zsh

Is it possible to make the CLI work with Fish?

@pjcdawkins
Copy link
Collaborator

For now, if you have the platform.rc file included, remove it. You won't have autocompletion unfortunately. This needs some investigation to support (in the symfony console completion library https://github.com/stecman/symfony-console-completion)

@pjcdawkins
Copy link
Collaborator

@dmsmidt since v2.6.0, I suppressed autocompletion error output so that the platform.rc file does not attempt to eval it, and you won't have a crash with Fish. Autocompletion won't work

@vincenzo
Copy link
Contributor

vincenzo commented Dec 1, 2017

I am fairly new to Fish shell, but support fish autocompletion should be just a matter of providing a man page for the platform cli? @pjcdawkins? @dmsmidt?

@stephenpurkiss
Copy link

`~/.config/fish/config.fish (line 5): Missing end to balance this if statement
if [ -f "$HOME/"'.platformsh/shell-config.rc' ]; then . "$HOME/"'.platformsh/shell-config.rc'; fi # END SNIPPET
^
from sourcing file ~/.config/fish/config.fish
called during startup

source: Error while reading file '/Users/stephenpurkiss/.config/fish/config.fish'
Welcome to fish, the friendly interactive shell`

This is what I get on install ~ am I to presume it's best just to drop out of fish into bash and use the CLI from there?

@yhoiseth
Copy link

yhoiseth commented Jan 4, 2019

In order to make it work with Fish (on Mac), i added the following to ~/.config/fish/config.fish:

set -gx PATH /Users/username/.platformsh/bin $PATH

Inspired by this comment.

I don't know what I'm missing by skipping the shell-config.rc stuff.

@yhoiseth
Copy link

Minor update to the above comment:

By running brew info node@10, I found out that Fish has a fish_user_paths variable which I now use instead:

set -g fish_user_paths "/Users/username/.platformsh/bin" $fish_user_paths

It seems like both methods work just fine, but I feel better about using the Fish-specific variable because I assume that whoever put it in the node formula knows what they're doing.

@gormus
Copy link

gormus commented Aug 19, 2019

From the Fish official documentation on $PATH:

set -U fish_user_paths /usr/local/bin $fish_user_paths

So, for Platform CLI:

set -U fish_user_paths /Users/USERNAME/.platformsh/bin $fish_user_paths

Example here uses the -U flag for universal, rather than -g global flag:

-U or --universal causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell.

-g or --global causes the specified shell variable to be given a global scope. Non-global variables disappear when the block they belong to ends

@rinchen
Copy link
Member

rinchen commented Mar 5, 2021

For clarity, this comment is from me as a user, not me as a Platform employee.

I was able to get the cli to work today with minor local changes. I had installed it already under zsh. I took a look at .bashrc and mapped it to Fish:

BASH: HOME=${HOME:-'/Users/joey'}
FISH: (may not be needed. $HOME is already set)

BASH: export PATH="$HOME/"'.platformsh/bin':"$PATH"
FISH: fish_add_path $HOME/.platformsh/bin
This ^^ was the only step I needed to make it work.

BASH: if [ -f "$HOME/"'.platformsh/shell-config.rc' ]; then . "$HOME/"'.platformsh/shell-config.rc'; fi #
FISH: if test -f $HOME/.platformsh/shell-config.rc
$HOME/.platformsh/shell-config.rc
end

shell-config.rc is more of the same as above. shell-config.rc and the associated shell-config-bash.rc are just nice to haves and thus I didn't need to execute it.

@andygeorge
Copy link

From the Fish official documentation on $PATH:

Just an update: like @rinchen mentions, you can now officially use fish_add_path instead of a set -U:

fish_add_path $HOME/.platformsh/bin

...which can also be added to ~/.config/fish/config.fish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants