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

Set shell interpreter seems not working for integrations #1660

Open
cgxxv opened this issue Mar 26, 2024 · 4 comments
Open

Set shell interpreter seems not working for integrations #1660

cgxxv opened this issue Mar 26, 2024 · 4 comments

Comments

@cgxxv
Copy link

cgxxv commented Mar 26, 2024

I have a lot of shell in my pc, my default shell is fish. While I don't want to write some fish shell for some lf integrations, I just want to use sh or bash for my integrations interpreter. It seems set shell sh not working.

The problem:
image

@joelim-work
Copy link
Collaborator

I'm guessing you have sh linked to fish, so with the default setting set shell sh, all shell commands will be interpreted by fish. If you want to use a different shell within lf, then just configure something like set shell bash.

@cgxxv
Copy link
Author

cgxxv commented Mar 26, 2024

@joelim-work Thanks for your replay. I don't have a linked sh for fish. But even I have a linked sh for fish maybe the better way is using the absolute path for this shell interpreter.

set shell bash

cmd rg_search ${{
    res="$( \
        RG_PREFIX="rg --column \
            --hidden \
            --line-number \
            --no-heading \
            --no-ignore \
            --glob '!.git/*' \
            --color=always \
            --smart-case "
        preview="
            filepath=\$(echo {}|awk -F ':' '{print \$1}')
            currentline=\$(echo {}|awk -F : '{print \$2}')
            startline=\$([ \$currentline -ge 50 ] && expr \$currentline - 50 || expr 0)
            endline=\$(expr \$currentline + 50)
            bat -n --line-range \$startline:\$endline --highlight-line \$currentline --color always \$filepath
        "
        FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
            fzf --bind "change:reload:$RG_PREFIX {q} || true" \
            --ansi --header 'Search in files' \
            --preview "$preview" \
            | cut -d':' -f1
    )"
    [ ! -z "$res" ] && lf -remote "send $id select \"$res\""
}}
map fs :rg_search

I use chsh to switch shell and test the case.
When I switched to zsh works fine, while with fish shell failed and show the top error. Not test for bash.

@joelim-work
Copy link
Collaborator

When executing shell commands (e.g. map x $var=123; echo "$var"), lf uses the shell that's configured using set shell ....

Your login shell (set using chsh) is not relevant here.


Here is a more minimal config example:

set shell bash
# set shell fish
# set shell zsh

map x $var=123; echo "$var"

For me set shell bash and set shell zsh work, but set shell fish doesn't, which is what I would expect since var=123 isn't valid syntax in fish.

@Trid-collab
Copy link

I am facing the same issue with integrations for my fish shell even though I have set shell fish
I found it works when I convert the integration to compatible with fish

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

No branches or pull requests

3 participants