From af3cdacab1f1b109462beba6798c8913a1fdbb42 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 4 Dec 2022 17:21:22 -0500 Subject: [PATCH] tmux: Move plumber to tmux-plumb to avoid name conflicts I've been playing around with a non-tmux plumber that will take the 'plumb' name! --- .tmux.conf | 12 ++++++------ bin/plumb | 51 --------------------------------------------------- bin/tmux-plumb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 57 deletions(-) delete mode 100755 bin/plumb create mode 100755 bin/tmux-plumb diff --git a/.tmux.conf b/.tmux.conf index 4e93de9..591ed9f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -10,19 +10,19 @@ set-option -g prefix C-a unbind-key C-b bind-key C-a send-prefix -# plumber! `a` in copy-mode sends to the 'plumb' command (A/Enter splits in new window) +# plumber! `a` in copy-mode sends to the 'tmux-plumb' command (A/Enter splits in new window) # right-click also opens in the current window (a la Acme) -bind-key -T copy-mode-vi a send-keys -X copy-pipe-no-clear "plumb #{pane_current_path}" -bind-key -T copy-mode-vi A send-keys -X copy-pipe-no-clear "plumb -w #{pane_current_path}" -bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "plumb -w #{pane_current_path}" +bind-key -T copy-mode-vi a send-keys -X copy-pipe-no-clear "tmux-plumb #{pane_current_path}" +bind-key -T copy-mode-vi A send-keys -X copy-pipe-no-clear "tmux-plumb -w #{pane_current_path}" +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "tmux-plumb -w #{pane_current_path}" bind-key -T root MouseDown3Pane \ select-pane \; copy-mode -M \; send-keys -X begin-selection \; \ send-keys -X previous-space \; send-keys -X other-end \; send-keys -X next-space-end \; \ - send-keys -X copy-pipe-and-cancel "plumb #{pane_current_path}" + send-keys -X copy-pipe-and-cancel "tmux-plumb #{pane_current_path}" bind-key -T copy-mode-vi MouseDown3Pane \ select-pane \; copy-mode -M \; send-keys -X begin-selection \; \ send-keys -X previous-space \; send-keys -X other-end \; send-keys -X next-space-end \; \ - send-keys -X copy-pipe-and-cancel "plumb #{pane_current_path}" + send-keys -X copy-pipe-and-cancel "tmux-plumb #{pane_current_path}" # Less delay on pressing escape (for vim) set-option -sg escape-time 10 diff --git a/bin/plumb b/bin/plumb deleted file mode 100755 index a17c764..0000000 --- a/bin/plumb +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# plumb -- plumber for tmux's copy-pipe -# reads the item to plumb from stdin, optionally takes a working dir -# most items open in a new tmux split, or new window if -w given -args=$(getopt w $*) -if [ "$?" != "0" ]; then - echo "usage: plumb [-w] [directory]" 1>&2 - exit 1 -fi - -set -- $args -while [ "$#" != "0" ]; do - case "$1" in - -w) NEW_WINDOW=1 ; shift ;; - --) shift ; break ;; - esac -done - -if [ -n "$1" ]; then - cd "$1" - shift -fi - -tmuxdo() { - if [ "$NEW_WINDOW" = "1" ]; then - tmux new-window sh -c "$1" - else - tmux split-window sh -c "$1" - fi -} - -# only accept first argument (by whitespace) -read ITEM -ITEM=$(echo "$ITEM" | awk '{ sub("^~", ENVIRON["HOME"], $1); print $1 }') - -case "$ITEM" in - http*) xdg-open "$ITEM" ;; - [a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*) \ - tmuxdo "git show $ITEM 2>&1 | less" ;; - [a-zA-Z0-9._-]*:[0-9]*:*) tmuxdo "fned \"$ITEM\"" ;; - [a-zA-Z0-9._-]*\([1-9]\)) - PAGE=${ITEM%%\([1-9]\)} - tmuxdo "man \"$PAGE\"" ;; - *) - if [ -d "$ITEM" ]; then - tmuxdo "cd $ITEM && $SHELL" - elif [ -e "$ITEM" ]; then - tmuxdo "${EDITOR:-vi} $ITEM" - fi - ;; -esac diff --git a/bin/tmux-plumb b/bin/tmux-plumb new file mode 100755 index 0000000..a17c764 --- /dev/null +++ b/bin/tmux-plumb @@ -0,0 +1,51 @@ +#!/bin/sh +# plumb -- plumber for tmux's copy-pipe +# reads the item to plumb from stdin, optionally takes a working dir +# most items open in a new tmux split, or new window if -w given +args=$(getopt w $*) +if [ "$?" != "0" ]; then + echo "usage: plumb [-w] [directory]" 1>&2 + exit 1 +fi + +set -- $args +while [ "$#" != "0" ]; do + case "$1" in + -w) NEW_WINDOW=1 ; shift ;; + --) shift ; break ;; + esac +done + +if [ -n "$1" ]; then + cd "$1" + shift +fi + +tmuxdo() { + if [ "$NEW_WINDOW" = "1" ]; then + tmux new-window sh -c "$1" + else + tmux split-window sh -c "$1" + fi +} + +# only accept first argument (by whitespace) +read ITEM +ITEM=$(echo "$ITEM" | awk '{ sub("^~", ENVIRON["HOME"], $1); print $1 }') + +case "$ITEM" in + http*) xdg-open "$ITEM" ;; + [a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*) \ + tmuxdo "git show $ITEM 2>&1 | less" ;; + [a-zA-Z0-9._-]*:[0-9]*:*) tmuxdo "fned \"$ITEM\"" ;; + [a-zA-Z0-9._-]*\([1-9]\)) + PAGE=${ITEM%%\([1-9]\)} + tmuxdo "man \"$PAGE\"" ;; + *) + if [ -d "$ITEM" ]; then + tmuxdo "cd $ITEM && $SHELL" + elif [ -e "$ITEM" ]; then + tmuxdo "${EDITOR:-vi} $ITEM" + fi + ;; +esac -- libgit2 1.1.1