Example:
2 panes.
Pane 1 current dir: /a/b/c/d
Pane 2 current dir: /a/f/g
I want to copy file.csv in current dir of pane 1 to current dir of pane 2.
What I do:
In pane 1:
cp file.csv ../../../f/g
It's slow and annoying to find the right relative path from the dir in pane 1 and I feel I could just "drag and drop" the file from one pane to the other.
Is there a way to do something analogous to a drag an drop?
Example of a "good" solution:
cp file.csv $pane2dir
Thanks
I have the following in my tmux.conf
# get directory from other pane using xsel
bind J run-shell -b -t bottom "echo -n #{pane_current_path} | xsel -i"
bind K run-shell -b -t top "echo -n #{pane_current_path} | xsel -i"
bind H run-shell -b -t left "echo -n #{pane_current_path} | xsel -i"
bind L run-shell -b -t right "echo -n #{pane_current_path} | xsel -i"
Often the pane that I want to copy to is to the left or right of my current pane. If it is to the right I would do <prefix> shift-l to put the current directory of the right pane in the clipboard.
To sort of satisfy your solution requirement one could modify this to create a command such as:
cp file.csv $(tmux run-shell -b -t right "echo -n #{pane_current_path} |xsel -i" && (sleep 0.01; xsel -o))
It would make sense to put that stuff in a shell script for convenience.
After giving my answer I played around a little bit and came up with the following
bind L if-shell -b -t right "tmux set-buffer -b panedir #{pane_current_path}" "paste-buffer -db panedir"
which puts the current directory of the "right" pane directly on the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With