kyoheiu / felix

tui file manager with vim-like key mapping
https://kyoheiu.dev/felix/
MIT License
689 stars 24 forks source link

[FEATURE REQUEST] File chooser mode #261

Open Rolv-Apneseth opened 6 months ago

Rolv-Apneseth commented 6 months ago

Just a possibility, but something like yazi's --chooser-file (or ranger's --choosefiles) flag would be very useful. This just writes the selected file(s) to a given file path instead of opening them directly. My use case is for using it in a Neovim plugin, such as others I have in my plugin tfm.nvim.

kyoheiu commented 6 months ago

Hi, could you let me understand this a little bit more?

I think this is similar to this issue of joshuto https://github.com/kamiyaa/joshuto/issues/96 . This feature would enable fx --chosefiles=/file/path command, and after the launch, the path of a file executed in felix would be added to /file/path text file with \n, right? For example, if I open ~/.config/felix/config.yaml with --choosefiles=~/sample.txt option, the full path of config.yaml would be written to ~/sample.txt.

I'd be appreciate if you teach me how this would work with the vim plugin.

Rolv-Apneseth commented 6 months ago

Sure yeah.

So for example when run with felix --choosefiles=~/sample.txt, I would want it to open felix normally, but when selecting a file, instead of opening it, just write it's path to ~/sample.txt, so that the selected file can be opened by something else. Hence it's just being used in a kind of file picker/chooser mode.

As a side note, is there currently a way of passing just a file path and having that file path focused when opening felix? Either it's own flag or just accepting any path instead of just directories. yazi just accepts the path to the file, and ranger has a --selectfile flag.

Rolv-Apneseth commented 6 months ago

By the way - very cool project, thanks for making it

kyoheiu commented 6 months ago

Sorry for the late reaction.

262 implements --choosefiles=/path/to/textfile option.

It'd be great if you check the behavior.

Edit: Oh, and the selectfile option is another story -- It might be worth considering, so I'll create a new issue about it.

Rolv-Apneseth commented 6 months ago

No problem, thanks for implementing this!

Checked it out and just 2 things (my opinion):

  1. If the file doesn't exist, it should just create it
  2. I believe it would be better to close the program once a file is selected. That's how other terminal file managers tend to do it

The use case for me is:

RioNight commented 6 months ago

I think it will be more ergonomic to first select a bunch of files in fx and enter :w /path/to/write/to in fx to write the selected files (or create another command instead of :w). That way you don't have to manually type fx --choosefiles="/some/path" to start fx. Then use can quit normally with :q. You can have also have a config option called exit-after-choosefiles or optionally ask the user to quit after choosing files, though the latter might get annoying if the user wants to "choose files" multiple times.

Rolv-Apneseth commented 6 months ago

Could be an option I guess, though hopefully --choosefiles would still be available

kyoheiu commented 5 months ago
  • If the file doesn't exist, it should just create it
  • I believe it would be better to close the program once a file is selected. That's how other terminal file managers tend to do it

@Rolv-Apneseth Fixed #262 in this way.

Rolv-Apneseth commented 5 months ago

Awesome, thank you.

Would it make more sense to override the file with the new path rather than just append the path to the existing file? It wouldn't make a difference for my use case though so for me it's fine as it is.

One more potential feature for this, how about being able to output multiple files with linewise visual mode? Absolutely not necessary but it would be nice. This could potentially be a separate feature, as, correct me if I'm wrong, but I don't think there's a way to open multiple files to edit at the same time right now?

kyoheiu commented 5 months ago

OK, I'll fix it to open in non-append mode. And about the linewise visual mode, it could be easy to add the feature to "open" multiple files with choosefiles option. In other options e.g. just fx, though, I might disable that feature because felix is just a tui file manager, and while it's completely normal to, e.g., open multiple images with macOS' preview, terminals are not created for that use case IMO.

kyoheiu commented 5 months ago

@Rolv-Apneseth Ok, fixed. Now

Rolv-Apneseth commented 5 months ago

That's awesome, works great!

kyoheiu commented 5 months ago

Merged to develop. It'll be published to crate.io and other package repositories after adding some other features.

Rolv-Apneseth commented 5 months ago

Nice, thanks for implementing this. I'll also subscribe to #263 and once that's done I'll be sure to include felix in tfm.nvim

kyoheiu commented 5 months ago

263 implemented in #272.

Rolv-Apneseth commented 5 months ago

Awesome, thank you. Sorry for the late reply, I've been away.

I have a couple of issues/suggestions (only if you have time of course - if you don't let me know and perhaps I could have a go):

  1. fx temp.txt doesn't work but fx ./temp.txt does, I think the ./ should be assumed if not given
  2. fx --choosefiles="temp.txt" ./temp.txt doesn't work, unfortunately this is the exact use case I need for the plugin. I noticed it doesn't work with ./ either so I'm guessing --choosefiles is blocking it in some way. Sorry for not catching that earlier.
  3. Just a suggestion, but I believe when focusing on a file with fx ./temp.txt, it shouldn't have the file at the very top of the view, maybe just center it on the file so you can see folders etc. above it
  4. This one is very minor but for the --choosefiles option, would it be possible to also have it work like this: fx --choosefiles temp.txt or would that complicate things?
kyoheiu commented 5 months ago

Ah.. This one is becoming a kind of yak-shaving, you might also know. While I'm positive for implementing an useful feature for users, I'm kind of doubtful now that if many of them actually touch this. I should have asked that, how many hackers do use your plugin?

Rolv-Apneseth commented 5 months ago

Yep fair enough, no need to do anything else if you don't want. I completely understand.

As for the plugin - no idea how many use it. Probably not all that many.

I will say though, these features are nice to have for being able to easily integrate this file manager into other programs, and the other major terminal file managers have these options. Realistically, if you want to leave it here, it is good enough as it is since choosefiles works and selecting the file is just a nice-to-have.