helix icon indicating copy to clipboard operation
helix copied to clipboard

feat: add `workspace_directory` and `current_working_directory` variable expansions

Open nik-rev opened this issue 8 months ago • 3 comments

Use case: Recently Yazi added out-of-the-box support for usage inside of Helix with with command:

[keys.normal]
space.E = [
  ':sh rm -f /tmp/unique-file',
  ':insert-output yazi %{buffer_name} --chooser-file=/tmp/unique-file',
  ':insert-output echo "\x1b[?1049h" > /dev/tty',
  ':open %sh{cat /tmp/unique-file}',
  ':redraw',
]

This replaces file_explorer_in_current_buffer_directory for me with a Yazi picker

I would like to be able to replace these two commands with Yazi as well:

  • file_explorer (uses workspace root)
  • file_explorer_in_current_directory (cwd)

This PR allows for that. Now you can do this too:

# file_explorer
space.e = [
  ':sh rm -f /tmp/unique-file2',
  ':insert-output yazi %{workspace_directory} --chooser-file=/tmp/unique-file2',
  ':insert-output echo "\x1b[?1049h" > /dev/tty',
  ':open %sh{cat /tmp/unique-file2}',
  ':redraw',
]
# file_explorer_in_current_working_dir
space.X = [
  ':sh rm -f /tmp/unique-file3',
  ':insert-output yazi %{workspace_directory} --chooser-file=/tmp/unique-file3',
  ':insert-output echo "\x1b[?1049h" > /dev/tty',
  ':open %sh{cat /tmp/unique-file3}',
  ':redraw',
]

nik-rev avatar Mar 10 '25 21:03 nik-rev

Regarding the recipe site this is already included.

pandalec avatar May 07 '25 10:05 pandalec

I would consider that a bug in the wiki. The wiki should not suggest things that aren't merged yet.

the-mikedavis avatar Jun 07 '25 13:06 the-mikedavis

I would consider that a bug in the wiki. The wiki should not suggest things that aren't merged yet.

Fixed by removing from the wiki

nik-rev avatar Jun 07 '25 15:06 nik-rev

I would consider that a bug in the wiki. The wiki should not suggest things that aren't merged yet.

Fixed by removing from the wiki

@nik-rev Now this is merged should it be added back or wait till it's in a release?

Also wonder if your space.e example above had a typo in it using %{buffer_name}(from your config) makes more sense to me because it takes you to the current buffer directory and highlights the file you're in.

Other random suggestion:

":open %sh{cat /tmp/unique-file-u41ae14 | head -n1}",

If you mark multiple files with yazi and press enter, :open won't be able to handle it. The above just uses the first one. Perhaps it could do something more clever to actually handle opening multiple buffers at once

willbush avatar Aug 09 '25 03:08 willbush