platformsh / legacy-cli

This is the legacy version of Platform.sh's command-line interface. The new version is at: https://github.com/platformsh/cli
https://docs.platform.sh/administration/cli.html
MIT License
224 stars 121 forks source link

Fish shell compatibility #358

Open dmsmidt opened 8 years ago

dmsmidt commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 6 years ago

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 commented 5 years ago

`~/.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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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 commented 3 years ago

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 commented 2 years ago

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.