From 174b78502223c37c95cba54bd95f6111e92edae0 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Sun, 23 Apr 2017 22:55:28 +0200 Subject: [PATCH] clean tmux config --- tmux.conf | 96 ++++++++++++++++--------------------------------------- 1 file changed, 27 insertions(+), 69 deletions(-) diff --git a/tmux.conf b/tmux.conf index b1877c5..099779e 100644 --- a/tmux.conf +++ b/tmux.conf @@ -8,90 +8,48 @@ set -g base-index 1 # colors set -g default-terminal "screen-256color" -# unicode -setw -g utf8 on -set -g status-utf8 on +# Use vim keybindings in copy mode +setw -g mode-keys vi # bah, C-B is ugly unbind C-b set -g prefix C-a bind C-a send-prefix -# Use vim keybindings in copy mode -setw -g mode-keys vi +# +# Smart pane switching with awareness of Vim splits. +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" + +is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" + +bind -n C-h run "($is_vim && tmux send-keys C-h) || \ + tmux select-pane -L" + +bind -n C-j run "($is_vim && tmux send-keys C-j) || \ + ($is_fzf && tmux send-keys C-j) || \ + tmux select-pane -D" + +bind -n C-k run "($is_vim && tmux send-keys C-k) || \ + ($is_fzf && tmux send-keys C-k) || \ + tmux select-pane -U" + +bind -n C-l run "($is_vim && tmux send-keys C-l) || \ + tmux select-pane -R" + +bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" # Setup 'v' to begin selection as in Vim bind-key -t vi-copy v begin-selection bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" -# Update default binding of `Enter` to also use copy-pipe -unbind -t vi-copy Enter -bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" - # splitting panes -bind v split-window -h -bind s split-window -v - -# moving between panes -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R - -# Pane resizing -bind -r H resize-pane -L 5 -bind -r J resize-pane -D 5 -bind -r K resize-pane -U 5 -bind -r L resize-pane -R 5 - -# Smart pane switching with awareness of vim splits -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" - -# status bar config -set -g status-left "#h:[#S]" -set -g status-left-length 50 -set -g status-right-length 50 -#set -g status-right "⚡ #(~/bin/tmux-battery) [✉#(~/bin/imap_check.py)] %H:%M %d-%h-%Y" -set -g status-right "%H:%M %d-%h-%Y" -setw -g window-status-current-format "|#I:#W|" -set-window-option -g automatic-rename off +bind | split-window -h +bind - split-window -v # listen to alerts from all windows set -g bell-action any # mouse support set -g mouse on - -# This tmux statusbar config was created by tmuxline.vim -# on Sun, 15 Feb 2015 - -set -g status-bg "colour235" -set -g message-command-fg "colour230" -set -g status-justify "left" -set -g status-left-length "100" -set -g status "on" -set -g pane-active-border-fg "colour33" -set -g message-bg "colour239" -set -g status-right-length "100" -set -g status-right-attr "none" -set -g message-fg "colour230" -set -g message-command-bg "colour239" -set -g status-attr "none" -set -g status-utf8 "on" -set -g pane-border-fg "colour239" -set -g status-left-attr "none" -setw -g window-status-fg "colour245" -setw -g window-status-attr "none" -setw -g window-status-activity-bg "colour235" -setw -g window-status-activity-attr "none" -setw -g window-status-activity-fg "colour33" -setw -g window-status-separator "" -setw -g window-status-bg "colour235" -set -g status-left "#[fg=colour230,bg=colour33] #S " -set -g status-right "#[fg=colour245,bg=colour239] %Y-%m-%d %H:%M #[fg=colour235,bg=colour244] #h " -setw -g window-status-format "#[fg=colour245,bg=colour235] #I #[fg=colour245,bg=colour235] #W " -setw -g window-status-current-format "#[fg=colour230,bg=colour239] #I #[fg=colour230,bg=colour239] #W "