Files
dotfiles/tmux.conf
Jim Myhrberg 7777b3e5ec Integrate Tmux pane switching with Emacs
When current pane is running Emacs, simply pass the pane switching keys
through to Emacs, so they can switch panes (called "windows") within
Emacs itself.

This allows a nearly seamless window/pane switching experience between
Emacs and Tmux.
2020-05-30 17:22:14 +01:00

98 lines
3.0 KiB
Bash

# Prefix Key
unbind C-b
set -g prefix C-q
bind C-q send-prefix
# Settings
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
set -g detach-on-destroy on
set -g history-limit 50000
set -g display-time 3000
set -g mouse on
# Pre-Tmux 2.6 macOS fix for pbcopy, pbpaste, and launchctl. Requires:
# brew install reattach-to-user-namespace
if-shell -b '[ "$(echo "$(tmux -V | cut -c 6-) < 2.6" | bc)" = 1 ] && [ -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
set -g visual-activity off
# Keybindings
bind r source-file ~/.tmux.conf
# Ctrl versions of default keybindings
bind C-c new-window
bind C-n next-window
bind C-p previous-window
bind C-l last-window
bind C-s choose-session
bind C-w choose-window
bind C-k confirm-before kill-window
# Kill window
bind k confirm-before kill-window
# Split window into panes
bind h split-window -h
bind v split-window -v
bind C-h split-window -h
bind C-v split-window -v
unbind i
bind u display-message
bind i select-pane -t :.-
bind C-i select-pane -t :.-
bind C-o select-pane -t :.+
unbind Enter
bind Enter resize-pane -Z
bind C-Enter resize-pane -Z
# Enable smart pane switching that's Emacs aware.
is_emacs='echo "#{pane_current_command}" | grep -iqE "(^|\/)emacs$"'
# Use Alt-[i/k/j/l] keys without prefix key to switch panes if current pane is
# not running Emacs. If the pane is running Emacs, let Emacs receive the
# keybindings instead.
bind -n M-i if-shell "$is_emacs" "send-keys M-i" "select-pane -U"
bind -n M-k if-shell "$is_emacs" "send-keys M-k" "select-pane -D"
bind -n M-j if-shell "$is_emacs" "send-keys M-j" "select-pane -L"
bind -n M-l if-shell "$is_emacs" "send-keys M-l" "select-pane -R"
bind -T copy-mode M-i if-shell "$is_emacs" "send-keys M-i" "select-pane -U"
bind -T copy-mode M-k if-shell "$is_emacs" "send-keys M-k" "select-pane -D"
bind -T copy-mode M-j if-shell "$is_emacs" "send-keys M-j" "select-pane -L"
bind -T copy-mode M-l if-shell "$is_emacs" "send-keys M-l" "select-pane -R"
bind -T copy-mode-vi M-i if-shell "$is_emacs" "send-keys M-i" "select-pane -U"
bind -T copy-mode-vi M-k if-shell "$is_emacs" "send-keys M-k" "select-pane -D"
bind -T copy-mode-vi M-j if-shell "$is_emacs" "send-keys M-j" "select-pane -L"
bind -T copy-mode-vi M-l if-shell "$is_emacs" "send-keys M-l" "select-pane -R"
# Toogle synchronize-panes without prefix key.
bind -n M-I setw synchronize-panes
#
# Plugins via TPM (https://github.com/tmux-plugins/tpm)
#
# Install TPM with:
#
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
#
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# Set Theme from tmux-themepack
set -g @themepack 'powerline/default/green'
# Configure tmux-yank
set -g @yank_action 'copy-pipe'
# Init Plugin Manager
run "${HOME}/.tmux/plugins/tpm/tpm"