From 8d10d95a1b3e8ad03be325f1741aea1e335afe34 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 13 May 2017 14:42:34 +0100 Subject: [PATCH] Update tmux config --- bin/login-shell | 12 ----------- bin/safe-reattach-to-user-namespace | 8 -------- tmux.conf | 31 +++++++++++++++++++---------- 3 files changed, 20 insertions(+), 31 deletions(-) delete mode 100755 bin/login-shell delete mode 100755 bin/safe-reattach-to-user-namespace diff --git a/bin/login-shell b/bin/login-shell deleted file mode 100755 index 2e6b52c..0000000 --- a/bin/login-shell +++ /dev/null @@ -1,12 +0,0 @@ -#! /usr/bin/env bash - -# Ensure that tmux windows are by default named after the shell, rather than -# full path to the shell binary. -shell=$(basename "$SHELL") - -# If reattach-to-user-namespace is not available, just run the command. -if [ -n "$(command -v reattach-to-user-namespace)" ]; then - reattach-to-user-namespace -l "$shell" -else - exec "$shell" -fi diff --git a/bin/safe-reattach-to-user-namespace b/bin/safe-reattach-to-user-namespace deleted file mode 100755 index 53abbfc..0000000 --- a/bin/safe-reattach-to-user-namespace +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env bash - -# If reattach-to-user-namespace is not available, just run the command. -if [ -n "$(command -v reattach-to-user-namespace)" ]; then - reattach-to-user-namespace $@ -else - exec "$@" -fi diff --git a/tmux.conf b/tmux.conf index ffa93e7..ffaf82d 100644 --- a/tmux.conf +++ b/tmux.conf @@ -8,20 +8,29 @@ set -g default-terminal "screen-256color" set -g detach-on-destroy on set -g history-limit 50000 -# Mouse support -set -g mouse on # Tmux 2.1 and later -set -g mode-mouse on -set -g mouse-select-pane on -set -g mouse-resize-pane on -set -g mouse-select-window on +# Mouse support (pre Tmux 2.1) +if-shell -b '[ "$(echo "$(tmux -V | cut -c 6-) < 2.1" | bc)" = 1 ]' \ + " \ + set -g mode-mouse on; \ + set -g mouse-resize-pane on; \ + set -g mouse-select-pane on; \ + set -g mouse-select-window on; \ + " -# Pre Tmux 2.1 mouse scrolling behavior -# - from: https://github.com/tmux/tmux/issues/145#issuecomment-151123624 -bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'" -bind -n WheelDownPane select-pane -t= \; send-keys -M +# Mouse support (Tmux 2.1 and later) +# - scrolling behavior from: https://github.com/tmux/tmux/issues/145#issuecomment-151123624 +if-shell -b '[ "$(echo "$(tmux -V | cut -c 6-) >= 2.1" | bc)" = 1 ]' \ + " \ + set -g mouse on; \ + bind -n WheelUpPane if-shell -F -t = \"#{mouse_any_flag}\" \"send-keys -M\" \"if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'\"; \ + bind -n WheelDownPane select-pane -t= \\; send-keys -M; \ + " # Mac OS X fix for pbcopy, pbpaste, and launchctl -set-option -g default-command "login-shell" +if-shell -b '[ -n "$(command -v reattach-to-user-namespace)" ]' \ + " \ + set-option -g default-command 'reattach-to-user-namespace -l $SHELL'; \ + " # Set window notifications setw -g monitor-activity on