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

[FEATURE REQUEST] File chooser mode #261

Open
Rolv-Apneseth opened this issue Dec 16, 2023 · 20 comments
Open

[FEATURE REQUEST] File chooser mode #261

Rolv-Apneseth opened this issue Dec 16, 2023 · 20 comments
Labels
enhancement New feature or request

Comments

@Rolv-Apneseth
Copy link

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
Copy link
Owner

kyoheiu commented Dec 17, 2023

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

I think this is similar to this issue of joshuto kamiyaa/joshuto#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.

@kyoheiu kyoheiu added the enhancement New feature or request label Dec 17, 2023
@Rolv-Apneseth
Copy link
Author

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
Copy link
Author

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

@kyoheiu
Copy link
Owner

kyoheiu commented Jan 1, 2024

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
Copy link
Author

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:

  • Open felix inside neovim, and have it focus the file that was being edited (this is where that other feature would be useful)
  • Select a different file from within felix, which writes this path to a file and closes, bringing you back to neovim
  • A plugin can then read that path and open the file in neovim

@RioNight
Copy link

RioNight commented Jan 6, 2024

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
Copy link
Author

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

@kyoheiu
Copy link
Owner

kyoheiu commented Jan 13, 2024

  • 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
Copy link
Author

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
Copy link
Owner

kyoheiu commented Jan 15, 2024

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
Copy link
Owner

kyoheiu commented Jan 19, 2024

@Rolv-Apneseth
Ok, fixed. Now

  • --choosefiles option always create or truncate an text file.
  • In linewise visual mode, if --choosefiles option is on, you can output multiple file paths by Enter, l or right arrow key.

@Rolv-Apneseth
Copy link
Author

That's awesome, works great!

@kyoheiu
Copy link
Owner

kyoheiu commented Jan 19, 2024

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

@Rolv-Apneseth
Copy link
Author

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
Copy link
Owner

kyoheiu commented Jan 20, 2024

#263 implemented in #272.

@Rolv-Apneseth
Copy link
Author

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
Copy link
Owner

kyoheiu commented Jan 24, 2024

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
Copy link
Author

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.

@lukeflo
Copy link

lukeflo commented Sep 4, 2024

Will the --choosefiles option be merged into main? BTW interesting project!

@kyoheiu
Copy link
Owner

kyoheiu commented Sep 29, 2024

At least until I understand what is the minimum to meet the demand, no, it won't.
But I'll keep this issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants