Skip to content

Commit

Permalink
fix: better clipboard detection
Browse files Browse the repository at this point in the history
  • Loading branch information
graelo committed Sep 1, 2023
1 parent 85fb9ec commit d5b997b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tmux-copyrat.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,23 @@ tmux bind-key ${keyswitch} switch-client -T ${keytable}
# Pattern bindings
#

if [[ "$OSTYPE" == darwin* ]]; then
setup_option "clipboard-exe" "pbcopy"
else
if [[ "$XDG_SESSION_TYPE" == wayland ]]; then
setup_option "clipboard-exe" "wl-copy"
else
setup_option "clipboard-exe" "xclip -selection clipboard"
fi
fi
clipboard_exe=$(tmux show-option -gv @copyrat-clipboard-exe)

setup_pattern_binding () {
key=$1
pattern_arg="$2"
# The default window name `[copyrat]` has to be single quoted because it is
# interpreted by the shell when launched by tmux.
tmux bind-key -T ${keytable} ${key} new-window -d -n ${window_name} "${BINARY} run --window-name '"${window_name}"' --reverse --unique-hint ${pattern_arg}"
tmux bind-key -T ${keytable} ${key} new-window -d -n ${window_name} "${BINARY} run --window-name '"${window_name}"' --clipboard-exe ${clipboard_exe} --reverse --unique-hint ${pattern_arg}"
}

# prefix + t + c searches for hex colors #aa00f5
Expand Down

0 comments on commit d5b997b

Please sign in to comment.