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

Feature request: customize which shell is used to execute aliases #163

Closed
j-hui opened this issue Feb 3, 2022 · 14 comments · Fixed by #166
Closed

Feature request: customize which shell is used to execute aliases #163

j-hui opened this issue Feb 3, 2022 · 14 comments · Fixed by #166

Comments

@j-hui
Copy link

j-hui commented Feb 3, 2022

I usually use Fish as my interactive shell, but the example aliases given use Bash syntax. For example:

ls = "zk list $@"

While I could change this to zk list $argv, I would instead like to specify which shell to use (instead of having it be determined by SHELL). This way, the same aliases will work whether I'm using Bash or Fish or any other shell.

@mickael-menu
Copy link
Collaborator

I guess I could add a config option like I did for PAGER, but I'd like to understand better your issue. Why do you need to use a different SHELL value for zk compared to the regular shell?

@j-hui
Copy link
Author

j-hui commented Feb 4, 2022

I guess I could add a config option like I did for PAGER

That would be perfect.

I'd like to understand better your issue. Why do you need to use a different SHELL value for zk compared to the regular shell?

To elaborate: fish does not support $@ syntax. Instead, it uses $argv.

Personally, I don't really like this about fish, but then again, I don't use it for scripting. I'd like to stick to POSIX shell syntax for zk aliases while still using fish as my interactive shell.

sxhkd has also encountered this issue, which it worked around using the SXHKD_SHELL environment variable. I'm looking for a similar workaround.

@mickael-menu
Copy link
Collaborator

I added ZK_SHELL in main, it was simpler than adding another config option for this.

@j-hui
Copy link
Author

j-hui commented Feb 6, 2022

Awesome, thanks!

@idr4n
Copy link

idr4n commented May 2, 2022

Hi,
How do I use this setting? I tried setting set -x ZK_SHELL "/bin/bash" in my fish config but still aliases are run with fish shell.

@mickael-menu
Copy link
Collaborator

mickael-menu commented May 2, 2022

I think you need the -g option with fish:
https://fishshell.com/docs/current/language.html#variables-scope

set -gx ZK_SHELL "/bin/bash"

@idr4n
Copy link

idr4n commented May 2, 2022

Since I'm setting the env variable outside a function, it really doesn't matter (-x or -gx). Nonetheless, I tried with -gx as well but still aliases are not run with the specified shell.

@mickael-menu
Copy link
Collaborator

What do you see if you run zk like this? (Assuming you have this alias ls = "zk list $@")

ZK_SHELL=echo zk ls

@idr4n
Copy link

idr4n commented May 2, 2022

Sorry, I'm not sure what you mean. If I run zk I get the zk usage message regardless whether I set ZK_SHELL to echo zk ls. In fish it would be set -gx ZK_SHELL $(echo zk ls). If I run zk ls I get the following:

image

@mickael-menu
Copy link
Collaborator

I installed fish and it seems to work for me. This is what I meant:

Screenshot 2022-05-02 at 17 35 53

@idr4n
Copy link

idr4n commented May 2, 2022

Ok, so apparently I had an older version when I installed zk with brew install zk, which was a couple of days ago so I though it had pulled the latest version. I reinstalled zk with brew install --HEAD zk and now it is working as desired 👍🏻... Thanks a lot for your time and for putting together a really nice app.

@mickael-menu
Copy link
Collaborator

Hmm yes, it looks like the Homebrew version was not updated automatically with the release, I need to take a look into that. Thanks for spotting this.

@mickael-menu
Copy link
Collaborator

Looks like someone already created it, so it should be available now: Homebrew/homebrew-core#100286

@idr4n
Copy link

idr4n commented May 2, 2022

Yes, I uninstalled and reinstalled with just brew install zk and it is picking up the 0.10.0 version. Thanks again!

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

Successfully merging a pull request may close this issue.

3 participants