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] Export lf options to shell commands #443

Closed
SeerLite opened this issue Aug 10, 2020 · 2 comments · Fixed by #448
Closed

[Feature request] Export lf options to shell commands #443

SeerLite opened this issue Aug 10, 2020 · 2 comments · Fixed by #448

Comments

@SeerLite
Copy link
Contributor

SeerLite commented Aug 10, 2020

I want a keybind that toggles between these two settings:

set nopreview
set ratios 1
set preview
set ratios 1:3:2

I couldn't come up with any way to get this behavior by reading the :doc. But two came to mind:

  1. Export lf options as shell variables (like Kakoune). Example: Exporting preview as $lf_preview (0/1).
%{{
    if [ $lf_preview -eq 1 ]; then
        # first setting here
    else
        # second setting here
    fi
}}
  1. Implementing return codes for lf -remote "send $id <...>" depending on if the command succeeded or not. This is a hackier solution but I figured it'd work since set preview will fail if ratios are not set up correctly. If the above is implemented instead, I think this would still have other uses (can't come up with any right now though).
%{{
    if ! lf -remote "send $id preview"; then
        # second setting here
    else
        # first setting here
    fi
}}

I hope I didn't miss a more obvious way to set this up, this is the best I could come up with after reading the doc for a bit.

And thanks for lf! I feel like it complements the Kakoune workflow a lot.

@gokcehan
Copy link
Owner

@SeerLite Thanks for the ideas. This is mentioned frequently but unfortunately not added yet. I think I'm in favor of the first option. I don't think this would be difficult to implement either. If anyone is interested, I think one should simply add a new function like app.exportOpts to be called in app.runShell that goes over all options in gOpts and export them as variables.

Anyway, closing this as a duplicate for #376

@gokcehan
Copy link
Owner

@SeerLite Or let's just keep this open since you describe the feature better than the other issue.

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

Successfully merging a pull request may close this issue.

2 participants