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

Shell is not set to zsh properly #467

Open
blake-weissman opened this issue Sep 14, 2020 · 15 comments
Open

Shell is not set to zsh properly #467

blake-weissman opened this issue Sep 14, 2020 · 15 comments
Labels

Comments

@blake-weissman
Copy link

In my lfrc I set my shell as zsh, however none of my aliases/zsh plugins seem to work. Is there anything I'm doing wrong/missing? In my lfrc I put set shell zsh.

@mohkale
Copy link

mohkale commented Sep 15, 2020

The only thing I can think of is that lf doesn't use a login/interactive shell for subprocesses. Which config file are you setting the aliases and installing the zsh plugins in? See here.

Try running zsh -c alias in a shell and see what it outputs, those are all the aliases lf exposes to subprocesses. There is an option in lf called shellopts. You could try setting it to -l or -i and see whether that fixes it. Although I wouldn't recommend doing that. Doing so we'll slow down your commands immensely. Frankly I wouldn't recommend relying on aliases inside of lf commands. If theses aliases are so essential you're using them in other places you should turn them into scripts or copy them as is into the cmd. Being a little non-DRY will save you a lot of headache IMO.

@blake-weissman
Copy link
Author

blake-weissman commented Sep 15, 2020

Running zsh -c alias outputs:
run-help=man which-command=whence

These are not my aliases. I tried settings shellopts to -l and -i and this did not work either. I also tried a few other shellopts. I'm setting my aliases and loading my plugins in my zshrc. Are there any examples of other lf builds that have zsh plugins + aliases working correctly?

@mohkale
Copy link

mohkale commented Sep 15, 2020

~/.zshrc Run for interactive shells.

zshrc is only run for interactive shells so you're gonna need -i to get it to be evaluated.
That's strange though. Are you using some sort of framework such as ohmyzsh or is it
a personal config?

I just tried

lf
:set shell zsh
:set shellopts -i
!alias

and it outputted the same aliases I have in zshell.

@mohkale
Copy link

mohkale commented Sep 15, 2020

Side Note: maybe try to track down where that run-help and which-command alias is being defined. Also double check lf is actually using zsh by running !echo $ZSH_VERSION.

@chama-chomo
Copy link

chama-chomo commented Oct 28, 2020

Hey, similar issue here.. I'm using ohmyzsh and my EDITOR is set to 'emacsclient -c'. It all works when I press o to open the application, but presisng l will always fail with below (no matter what changes I'm doing in the config):

zsh:4: command not found: emacsclient -c

Thanks for any hint.

@mohkale
Copy link

mohkale commented Oct 28, 2020

@chama-chomo Sounds to me like this is a quoting issue. zsh by default doesn't use the same substitution approach as bash.

foo="hello world"
$foo

in bash a program named hello is run with a world argument. In zsh it tries to run a program called hello world.

You can get the same affect as bash by setting shwordsplit (setopt shwordsplit). Try putting that in your zprofile and see whether this is still an issue.

@chama-chomo
Copy link

Thanks for the advice, but nothing changes after applying shwordsplit option. I tried with bash, too, a similar problem reported by lf

--: line 3: emacsclient -c: command not found

@mohkale
Copy link

mohkale commented Oct 28, 2020

@chama-chomo Oh, seems like this is an lf issue. Not a shell one. But I can't quite track down why so we should ask the main developer. I've actually had this same issue with OPENER in the past but just assumed that was how OPENER is supposed to work. It's common to try to supply arguments to an EDITOR so we should really account for this.

@gokcehan My findings so far:

  • EDITOR='command -flag' lf makes lf unable to open files because lf tries to run a command named command -flag instead of command with an argument -flag.
  • Doing !sh -c '$EDITOR "$f"' works fine, so I suspect the quoting issue is with lf and not the shell.

I'll look more into how lf does this to try and see what's causing it.

@gokcehan
Copy link
Owner

@mohkale Thanks a lot for helping with the issues.

@chama-chomo I think you are setting the option ifs to a value without spaces, so your alias isn't split as you expect. It is a duplicate for #141 which is different than the original issue reported here.

@chama-chomo
Copy link

thanks @gokcehan , that makes sense. #141 indeed resolves my issue.
Btw, do you find too crazy setting $EDITOR to xdg-open command? I've resolved all my issues applying that, besides lf is not blocked after opening the editor, which is nice. Wondering what other caveats this change might have.

@blake-weissman
Copy link
Author

@mohkale

Apologies for the late response. Using set shellopts -i technically works but using any shell commands with this setting crashes/quits lf and returns zsh: suspended (tty output) lf -last-dir-path="$tmp" "$@", but it does allow alliases to work. Is this a known issue and if so is there any way to get this working without having lf quit? Fyi I'm not using any kind of zsh framework, just a personal config.

@mohkale
Copy link

mohkale commented Oct 31, 2020

@blakeweissman That output makes it sound more like lf has gone into the background rather than crashed. You should be able to reopen it with the fg command. I think this is a known issue. I've got map S $$SHELL in my config and whenever I run it and then exit the shell, lf comes back as suspended.

I don't think this is an lf issue, it's a zsh one. If I change my shell to bash and run lf and repeat the same process.

  1. SHELL=bash lf
  2. S
  3. exit

lf is never suspended.

In the past I tried to track down what option was causing this, but no dice on my end. You might have more help reaching out to some active zsh developers/communities (try r/zsh).

S.N. I hope you haven't been exiting shells with leftover background jobs 🤣.

@gokcehan
Copy link
Owner

gokcehan commented Nov 1, 2020

@chama-chomo It's not crazy if it works for you. I think it requires you to configure your xdg-open to open text files with the editor and also in the same terminal. And sometimes you want to be explicit about opening a file in an editor even though you are using a different program set to open the corresponding file type. Besides these, I don't know if there are any disadvantages.

@blakeweissman It sounds like you bumbed into #480 which is an open bug that I can't do much at the moment. The original issue reported about aliases not being available should probably be considered by design. We simply wrap the commands within sh -c ... and shells do not export aliases for such non-interactive use. Instead of -i option, I think you may also try adding source ~/.zshrc to the commands where you make use of your aliases, although I agree with @mohkale that it is better simply to expand your aliases manually inside the commands.

@mohkale
Copy link

mohkale commented Nov 15, 2020

@blakeweissman

Could you try updating to zsh 5.8 and letting me know whether suspending is still a problem? I'm not experiencing it anymore and I've been making quite a few changes to my dotfiles over the past few days. One of those settings could've fixed the issue or zsh itself patched out the problem.

@blake-weissman
Copy link
Author

@mohkale Again my bad for the late response, life can sometimes get in the way. I'm experiencing the issue on zsh 5.8-1. Also yes, it turns out I've been exiting shells with existing background jobs lol. Using fg after lf "crashes" results in lf starting back up with the same state. I'm planning to perform a reinstall of my current Linux setup soon so I'm curious to see if it will fix the issue on it's own. I'll post an update on this thread if the issue fixes itself. I would't be surprised if the issue ends up going away because my current install was set up when I was basically completely new to Linux.

@gokcehan I'll keep an eye out on that issue in case I can find a solution, thanks.

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

No branches or pull requests

4 participants