jarun / nnn

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

[Question] Any way to choose which applications to open the file with "open with" function? #1450

Closed amalgame21 closed 2 years ago

amalgame21 commented 2 years ago

In ranger, there is a rifle.conf that list out all the possible application that could be used to open a specific file. The first application on top of the list for that specific file in rifle.confwas set to default. It also detect which application was installed on the system. When press enter or l, the default application will be launched. When press r, there will be a list of application to choose from by typing 1, 2, 3, and so on, or simply type the full name of the application there like "open with" in nnn.

I think nuke in nnn is somewaht similar to rifle.conf in ranger. nuke is nice, I love it, which bypass the complicated xdg-open. But it seems only define the default application to open, by detecting which application was installed. I cannot choose between applications to open in nuke on the fly.

The "open with" function by pressing o or ^O seems can be used to override nuke default. But it cannot choose which application to open the file. Some applications' name are very hard to remember to me, such as aegisub-3.2, okular, zathura, ristretto and I have to spell it perfectly right to launch the application. And there is no auto-completion for the application in the "open with" prompt.

Maybe I missed something in the Wiki?

amalgame21 commented 2 years ago

And how can I cancel the "open with" action after I press o or ^O? Esc and ^C seems not working.

amalgame21 commented 2 years ago

Just find out that I can use the = key to launch the applications with fzf search. But it only launch the app, like what dmenu does.

Any way to use this to launch the application and use the highlighted item as argument??

N-R-K commented 2 years ago

What you're trying to do should be easily achievable via either editing nuke or by writing a plugin yourself.

Take a look at plugin documentation or take a look at some of the simpler plugins like suedit to get started.

0xACE commented 2 years ago

Plugins can be launched via Alt-<key>. You could create a script that manages your needs.

If implementing what you need in bash is too much work, go a head and create a python-script and maybe utilize sqlite if you prefer.

Be creative. Has nnn blinded your intuition in using the shell?

N-R-K commented 2 years ago

@0xACE insane timing, right when I pressed "comment" as well. Almost thought it was my comment that somehow got distorted..

jarun commented 2 years ago

Also, check out xstarter. Closing the defect as there are alternative ways.

amalgame21 commented 2 years ago

What you're trying to do should be easily achievable via either editing nuke or by writing a plugin yourself.

Take a look at plugin documentation or take a look at some of the simpler plugins like suedit to get started.

Thanks for your advice. I though it is a basic function that a file manager should have. I was expecting that I just missed something on the wiki, didn't expect that this functionality is not yet implemented for such a long time for built-in or plugin.

Not all of the users are programmer, some of them may have zero knowledge of programming. Lack of some key function may scare them away.

After looked into some plugins to learn what is going on with the code as you advised , I finally highly modified the nuke plugin, so now it can be work as either a "plugin" as what nuke does, or work as "commands as plugin" to add a function to choose applications other then default one to play files by file type or mime. However it is not well tested, some function may be broken.

How can I submit it?

amalgame21 commented 2 years ago

Plugins can be launched via Alt-<key>. You could create a script that manages your needs.

If implementing what you need in bash is too much work, go a head and create a python-script and maybe utilize sqlite if you prefer.

Be creative. Has nnn blinded your intuition in using the shell?

I am just a linux beginner normal user switching from Windows last year, and have no python and sqlite knowledge at all :(. To me bash is much easier because I learnt some of it to use the crontab job. I heavily modified the nuke plugin and add the function to it as "command as plugin". Thanks for your advice!

jarun commented 2 years ago

I though it is a basic function that a file manager should have. I am just a linux beginner normal user switching from Windows last year, and have no python and sqlite knowledge at all

You should really start with a basic file manager, get accustomed to the basics and then try something like nnn.

jarun commented 2 years ago

nnn is way too advanced and needs more expertise to use.

amalgame21 commented 2 years ago

I though it is a basic function that a file manager should have. I am just a linux beginner normal user switching from Windows last year, and have no python and sqlite knowledge at all

You should really start with a basic file manager, get accustomed to the basics and then try something like nnn.

Ya When he mentioned sqlite,I cannot even think of how it can be used together with nnn...

But now it is fine after modifying nuke plugin for this job. Much easier to use other applications to launch some files just like ranger r key.

nnnis much better thanranger to me now. nnn is more usable for small monitor like termux. ranger is function-rich, but extremely slow in raspberry pi. Maybe later will give lf a try if I encounter some technical problem cannot be solved by myself. But now it is good.

amalgame21 commented 2 years ago

For someone may need this function: https://raw.githubusercontent.com/amalgame21/conifg/main/nuke_select

Just add code on top of nuke plugin and rename to nuke_select Use "command as plugin" syntax to use the added feature, as described in the file. Work with bash, other shell seems not work. May have to change the first line of the plugin to point to bash. Not well tested, may have bug. Not good code but should work.