joshuto icon indicating copy to clipboard operation
joshuto copied to clipboard

Add a new feature: fzf bookmarks

Open Jacky-Lzx opened this issue 1 year ago • 2 comments

I'm implementing fzf bookmarks inspired from ranger-fzf-marks, which is a plugin I use everyday in ranger, and I'd like to have it as well in joshuto.

It acts as follows:

  • fzf_add_mark [markname] creates a new line in file $HOME/.fzf-marks, with the format markname : current_directory.
  • fzf_cd_mark opens a fzf selection window to select a bookmark, and then cd to that directory in joshuto.

See it in the following video:

https://github.com/kamiyaa/joshuto/assets/49983642/e33f197c-74d9-4559-8663-c8972e54bfa3

Jacky-Lzx avatar May 25 '23 15:05 Jacky-Lzx

I don't know if you like it. Maybe I'm the only one using it everyday. I'd like to make it as a plugin in the feature.

If you like it, please give me some comments about my codes and I'll adjust them. I'm new to rust. And I'll add documents before merging.

Jacky-Lzx avatar May 25 '23 15:05 Jacky-Lzx

It's inspiring to see such high-quality open-source projects.

tracy0880550287 avatar May 27 '23 15:05 tracy0880550287

Updated the document.

Jacky-Lzx avatar May 28 '23 12:05 Jacky-Lzx

Hi! Just some thoughts from my side:

IMHO, this is a pretty specific feature which would be more suited for a plugin or an external script. Joshuto has no plugin concept, but in context of #241, I proposed that we can “chain” commands for key-chords and that we can provide the output of the last spawn command as variables the following commands. If I understood this feature right, it should be doable with minimal external scripting then.

The keymap might have stuff like this then:

keymap = [
  {
    keys = [ "f ", "z", "a" ],    # fuzzy add
      command = [
        "shell add_current_dir_to_marks.sh {dir}",     # {dir} gets substituted by the current directory of the current tab
      ]
  },
  {
    keys = [ "f", "z", "c" ],    # fuzzy change
      command = [
        "shell fuzzy-pick-from-marks.sh",
        "cd {stdout}"      # {stdout} gets substituted with the stdout of the last `shell` command
      ]
  },
]

The only difference would be that one has to ask for the “mark name” from the script instead of giving it as parameter in Joshuto's command line.

What do you think?

DLFW avatar May 29 '23 12:05 DLFW

Oh yes. Your solution makes more sense to me as well. I might think about it when I have spare time.

Jacky-Lzx avatar May 30 '23 02:05 Jacky-Lzx