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

Current helper binaries are incompatible with fish #264

Closed
1 task done
marcoluzi opened this issue Oct 3, 2023 · 6 comments
Closed
1 task done

Current helper binaries are incompatible with fish #264

marcoluzi opened this issue Oct 3, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request. fixed in upcoming release Fixed in the upcoming release!

Comments

@marcoluzi
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and discussions

Is this feature request related to a problem?

The fish terminal apparently ignores the #!/bin/zsh when i run . pm74 or source pm74. It wants to run the script with the fish syntax and thus returns the following error:

pm74 (line 5): $  is not a valid variable in fish.
[[ $ZSH_EVAL_CONTEXT =~ :file$ ]] \
                              ^
from sourcing file pm74
source: Error while reading file 'pm74'

Describe the solution you'd like to see

Add support for fish shell. Maybe some sort of shell checking when the helper binaries are created.

Additional information or context

No response

@marcoluzi marcoluzi added the enhancement New feature or request. label Oct 3, 2023
@nicoverbruggen
Copy link
Owner

For this to work, I’d need to detect which shell is in use. This is possible with an additional command.

What is the output of these two commands on your system?

echo $SHELL
dscl . -read ~/ UserShell | sed 's/UserShell: //

That will help me determine which command to use to determine whether Fish is in use. Thanks!

@marcoluzi
Copy link
Author

Same output for both:
/opt/homebrew/bin/fish

@nicoverbruggen
Copy link
Owner

Thanks. I'll see if I can't get this to work later now that I know I can check if fish is in use.

(I did a few experiments already, and I'm not sure I can make it work as seamlessly as it currently does with bash/zsh.)

@nicoverbruggen nicoverbruggen added the investigation needed Further investigation is needed at some point label Oct 3, 2023
@nicoverbruggen nicoverbruggen changed the title [Feature] Add fish support for helper binaries Current helper binaries are incompatible with fish Oct 3, 2023
@nicoverbruggen
Copy link
Owner

@marcoluzi Good news, I've got this working. I can now detect if the default user shell is Fish, and if so, a Fish-compatible version of the scripts are generated.

Unfortunately, unlike zsh, sourcing scripts requires you to provide the full path to the file you wish to source. The files to be sourced are always generated in ~/.config/phpmon/bin. Fortunately, Fish helps with autocomplete :)

Example usage:

Screenshot 2023-10-20 at 17 20 55

Like the other scripts, the variable is only set for the current terminal session! (This doesn't use fish_add_path, which adds to your $PATH permanently. That isn't the intention, obviously.)

So you can use source ~/.config/phpmon/bin/pm80 for PHP 8.0, and so on.

Please try out this DEV build and let me know if it works as described: phpmon-dev.zip


Note: Fish compatible files are only generated if your default shell ($SHELL) contains the substring /fish. To accomplish this on modern macOS, you need to add the binary to /etc/shells and set it with chsh.

According to the output you posted above, this should not be an issue, but for others this may be relevant information:

echo "/opt/homebrew/bin/fish" | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish

@nicoverbruggen nicoverbruggen removed the investigation needed Further investigation is needed at some point label Oct 20, 2023
@marcoluzi
Copy link
Author

@nicoverbruggen
That's awesome. Thank you so much. <3
Works perfectly fine.

@nicoverbruggen nicoverbruggen added the fixed in upcoming release Fixed in the upcoming release! label Oct 29, 2023
@nicoverbruggen
Copy link
Owner

Fantastic. This is now included in v6.2, which I've just released! Closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request. fixed in upcoming release Fixed in the upcoming release!
Projects
None yet
Development

No branches or pull requests

2 participants