Skip to content

Commit feb9611

Browse files
committed
Add @override_copy_command to force copy command.
Fixes #90
1 parent 68c5c7c commit feb9611

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,31 @@ Configuration
171171
- <kbd>Y</kbd> (shift-y) — "put" selection. Equivalent to copying a
172172
selection, and pasting it to the command line.
173173
174+
175+
### Default and Preferred Clipboard Programs
176+
177+
tmux-yank does its best to detect a reasonable choice for a clipboard
178+
program on your OS.
179+
180+
If tmux-yank can't detect a known clipboard program then it uses the
181+
`@custom_copy_command` tmux option as your clipboard program if set.
182+
183+
If you need to always override tmux-yank's choice for a clipboard program,
184+
then you can set `@override_copy_command` to force tmux-yank to use whatever
185+
you want.
186+
187+
Note that both programs _must_ accept `STDIN` for the text to be copied.
188+
189+
An example of setting `@override_copy_command`:
190+
191+
``` tmux
192+
# ~/.tmux.conf
193+
194+
set -g @custom_copy_command 'my-clipboard-copy --some-arg'
195+
# or
196+
set -g @override_copy_command 'my-clipboard-copy --some-arg'
197+
```
198+
174199
### Linux Clipboards
175200
176201
Linux has several cut-and-paste clipboards: `primary`, `secondary`, and

scripts/helpers.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ shell_mode_option="@shell_mode"
2727
custom_copy_command_default=""
2828
custom_copy_command_option="@custom_copy_command"
2929

30+
override_copy_command_default=""
31+
override_copy_command_option="@override_copy_command"
32+
3033
# helper functions
3134
get_tmux_option() {
3235
local option="$1"
@@ -75,6 +78,10 @@ shell_mode() {
7578
custom_copy_command() {
7679
get_tmux_option "$custom_copy_command_option" "$custom_copy_command_default"
7780
}
81+
82+
override_copy_command() {
83+
get_tmux_option "$override_copy_command_option" "$override_copy_command_default"
84+
}
7885
# Ensures a message is displayed for 5 seconds in tmux prompt.
7986
# Does not override the 'display-time' tmux option.
8087
display_message() {
@@ -108,7 +115,9 @@ command_exists() {
108115

109116
clipboard_copy_command() {
110117
# installing reattach-to-user-namespace is recommended on OS X
111-
if command_exists "pbcopy"; then
118+
if [ -n "$(override_copy_command)" ]; then
119+
override_copy_command
120+
elif command_exists "pbcopy"; then
112121
if command_exists "reattach-to-user-namespace"; then
113122
echo "reattach-to-user-namespace pbcopy"
114123
else

0 commit comments

Comments
 (0)