make "y" copy independent of a display server
m040601 opened this issue · 2 comments
First of all thank your work on this really interesting tool. I found it via suckless.org and the termbox library links. Nice to know you're also an Archlinux user. It really deserves a post there on the forum.
You can press y to copy a selected item into X or Wayland clipboard. Note that you must have xsel or wl-copy installed (depending on whether you use X or Wayland) to use the command.
You also can press o to write a path to standard output and exit program. It may be useful in a system without a display server.
So, by default, "y" is binded to a clipboard action. When one is not using X11/Wayland it doesnt do anything.
Since I'm using tmux, without X11 I tried in ~/.config/ictree/config
map y echo "$f" | tmux load-buffer -
And it worked !
So, my suggestion, instead of hard coding "y" to use xsel etc,
Maybe you could probe for a $DISPLAY environement (returning false), and a $TMUX environment (returning true). If both check then map y to the tmux copy buffer.
By the way,
You can define custom commands in a configuration file
to open selected path in another program (e.g. an image viewer or a text editor):
open file in $EDITOR
map e $EDITOR $f
You might want to add to the README/man page a word or two about quoting that $f.
Apparently ictree sends $f unquoted.
I first tried
map e $EDITOR $f
or
map i $PAGER $f
But very often my folders and files have spaces, so it failed.
I had to
map e $EDITOR "$f"
or
map i $PAGER "$f"
Maybe you could probe for a $DISPLAY environement (returning false), and a $TMUX environment (returning true). If both check then map y to the tmux copy buffer.
That's a good idea, will do!
You might want to add to the README/man page a word or two about quoting that $f.
Added quotes in examples: b561d0e . I think that should suffice?