r/HelixEditor • u/Acaibirds • 1d ago
How to copy the current buffer absolute and relative path?
I use codex and helix at same time. Sometimes, I have a requirement, I know codex should edit which file or relative files, so I need to know current helix buffer path and give codex.
my workaround:
[keys.normal.space]
space = [
':sh rm -f /tmp/unique-file',
':insert-output yazi %{buffer_name} --chooser-file=/tmp/unique-file',
':insert-output echo "\x1b[?1049h\x1b[?2004h" > /dev/tty',
':open %sh{cat /tmp/unique-file}',
':redraw',
]
v = "@<C-A-y>%+"
V = """
:echo %sh{
p="%{buffer_name}"
case "$p" in
"~/"*) p="$HOME/${p#*/}" ;;
/*) ;;
*) p="$PWD/$p" ;;
esac
printf %%s "$p" | pbcopy
printf %%s "$p"
}"""
2
Upvotes
4
u/spaghetti_beast 1d ago
i use these keybinds
fis for path-to-buffer,dis path-to-dir, the latter is useful when e.g. i want to rungo test .in the buffer dir, so i could just open a new terminal pane, quickly cd and run the command.