jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.19k stars 758 forks source link

nuke: expansion of $VISUAL variable #1097

Closed basbebe closed 3 years ago

basbebe commented 3 years ago

I'm having a problem with nuke and I can't figure out why (probably because I'm not an expert with bourne shell and it's string expansions (?).

My $VISUAL variable consists of two words:

VISUAL=kcr edit

nuke uses it as follows:


[…]

EDITOR="${VISUAL:-${EDITOR:-vi}}"

[…]

        text/* | */xml)
            "$EDITOR" "${FPATH}"
            exit 0;;

[…]

No I'm getting errors like whit when I want to edit a text file:

/Users/bastian/.config/nnn/plugins/nuke: line 448: kcr edit: command not found

using kak as a visual editor works. using e works with kcr edit set as $EDITOR.

$PATH is not an issue here. I already tried around with various combinations of quotes and curly braces but I wasn't succesful.

(Im using kak as an editor, kcr edit comes from kakoune.cr)

0xACE commented 3 years ago

My $VISUAL variable consists of two words:

cap


mkdir -p ~/bin
export PATH=$PATH:~/bin
cat <<EOF > "$HOME/bin/kcr-edit"
#!/usr/bin/env sh
kcr edit "$@"
EOF
chmod +x ~/bin/kcr-edit
export VISIUAL=kcr-edit

cap

basbebe commented 3 years ago

My $VISUAL variable consists of two words:

cap

I know, I know

It's a pragmatic workaround but I thought there was something about nuke's code which I could look at since I don't have any problems with it anywhere else (including nnn).

jarun commented 3 years ago

@luukvbaal any quick way to handle this case in nuke?

luukvbaal commented 3 years ago

Best way to handle it is like @0xACE suggested or just directly replace EDITOR with kcr edit in nuke.

jarun commented 3 years ago

Closing as we have shared some solutions for this. Plugins are indicative so it's expected users would have to adapt them.