From 6fe053f5f614869a8306e31d3979af76432b3bae Mon Sep 17 00:00:00 2001 From: Micke Lisinge Date: Wed, 4 Nov 2015 10:17:29 +0100 Subject: [PATCH] Add tmux search bind. Press `S` to search google for the selected text in copymode --- tmux.conf | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tmux.conf b/tmux.conf index 58d1c69..d8a2c8a 100644 --- a/tmux.conf +++ b/tmux.conf @@ -14,11 +14,12 @@ set -g history-limit 20000 bind = select-layout even-horizontal # Smart pane switching with awareness of vim splits -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' +bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" set-window-option -g mode-keys vi @@ -87,7 +88,9 @@ set-option -g display-panes-active-colour blue #blue set-option -g display-panes-colour brightred #orange # clock -set-window-option -g clock-mode-colour green #green) +set-window-option -g clock-mode-colour green #green + +bind-key -t vi-copy S copy-pipe "xargs -I {} tmux run-shell 'cd #{pane_current_path}; open https://google.com/search?q=\"{}\" > /dev/null'" bind-key -n M-1 select-window -t 1 bind-key -n M-2 select-window -t 2