legacy-cli
legacy-cli copied to clipboard
Fish shell compatibility
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?
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)
@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
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?
`~/.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?
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.
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.
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
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.
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
.