Open blake-weissman opened 3 years ago
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.
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?
~/.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.
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
.
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.
@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.
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
@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
.!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.
@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.
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.
@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.
@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.
SHELL=bash lf
S
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 :rofl:.
@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.
@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.
@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.
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
.