-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
rework SEL_OPENWITH, add example plugin openwith #2007
Conversation
printf "%s/%s" "$2" "$1" >"$selection" | ||
fi | ||
|
||
xargs -0 -I{} $command <"$selection" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we should maybe do to allow using xargs within xargs
xargs -0 -I{} sh -c "$command" <"$selection"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This takes away a built-in functionality and turns it into a plugin with external dependencies. This is a severe regression. Not everyone has plugins installed or might be using nnn in a remote environment with no configuration.
Why can't this be a regular plugin, which you can bind to o
and then invoke with alt+key (alt+o in this case)?
Also, nnn already supports running arbitrary shell commands over selection via the builtin shell prompt (bound to ]
). E.g echo "%j"
will run the command for each file and "%J"
will run it for all files at once.
if variable isn't defined it works as previous implementation
That's great, didn't know about this. I see now, it's documented wiki/Concepts#prompts Surely this can be plugin but not everyone uses 'o' key and this could extend functionality. I know this is matter of person, for me 'o' was dead key, because of limited auto-completion (almost none). Most of the time in my workflow I do Plugin itself is half-baked nothing interesting to add, just provides fzf with $PATH or history, then you can edit command in your editor and run it over selection. I just wanted to provide example how to work with selection. I think it solves Maybe you should make repository/directory with not only plugins in one place, but also custom patches, would be nice. I like idea that nnn feels like lego, you start minimal you grow to something bigger. I could go over my free time, collect all interesting patches from issues, discussion... if you're interested
You spawned idea in my head. Instead of doing plugin like I did, I could define
|
Ah, you're right, I missed the fall though. But in any case, I'm still not convinced that this should be built in. A plugin would also solve problem 1 & 3. In fact plugin system exists precisely so that we don't have to support every little preference of every user, they get to write a local plugin that caters to their needs. |
You could also just use a function like this in your shellrc (I'm assuming posix like syntax): nnnxargs()
{
xargs -0 "$@" < "$NNN_SEL"
} Then use this inside of the nnn spawned shell. Less hacky although a bit more typing. |
This solves 3 problems which user might have upon pressing 'o' key:
git add
or anything more complicatedScript
openwith
doesn't clear.selection
because I was not sure if I should give it$NNN_SEL
.What do you think?