Dotfiles/site-modules/core/files/tmux.conf
Ade Attwood bb66289983 feat(shell): integrate the emacs better into the terminal
There a quite a few fixes and feature here to make the terminal experience of
emacs better. Most of this is only enabled when running in the terminal.

1) Better tmux integration with navigating between splits and also highlighting
the active window between emacs and tmux so you can better see the active window
you are working in.

2) Mouse and clipboard support through the x window manager so "yank" copies
text into the system clipboard

3) Changing the cursor style between insert and normal mode inside the terminal
this is not the case in default evil mode.
2021-07-08 09:03:27 +01:00

154 lines
4.9 KiB
Bash

# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
# Smart pane switching with awareness of vim splits
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$|emacs'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
#
# Set color term
#
set-option -sg escape-time 10
set-option -g default-terminal "xterm-256color"
#
# Set long history
#
set-option -g history-limit 5000
# resize panes like vim
# feel free to change the "1" to however many lines you want to resize by, only
# one at a time can be slow
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
# bind : to command-prompt like vim
# this is the default in tmux already
bind : command-prompt
# vi-style controls for copy mode
setw -g mode-keys vi
# set windows so they dont resize to the smallest
setw -g aggressive-resize on
# use mouse on
set -g mouse on
set-option -g mouse on
set -g @open-S 'https://www.duckduckgo.com/'
set -g @open-editor-command 'emacs --no-wait'
# Init plugins
run-shell ~/.tmux/plugins/tmux-copycat/copycat.tmux
run-shell ~/.tmux/plugins/tmux-open/open.tmux
run-shell ~/.tmux/plugins/tmux-yank/yank.tmux
# Automatically renumber window numbers on closing a pane (tmux >= 1.7).
set -g renumber-windows on
# Stay in copy mode on drag end.
# (Would use `bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X
# stop-selection` but it is a bit glitchy.)
unbind-key -T copy-mode-vi MouseDragEnd1Pane
# Search back to last prompt.
bind-key b copy-mode\; send-keys -X start-of-line\; send-keys -X search-backward "⇒"\; send-keys -X next-word
# Set `v` key to start selection like vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
# Start window and pane numbering at 1, (0 is too hard to reach).
set -g base-index 1
set -g pane-base-index 1
# Needed as on tmux 1.9 and up (defaults to off).
# Added in tmux commit c7a121cfc0137c907b7bfb.
# Also need by vim plugin tmux-focus-events.vim
set -g focus-events on
# Powerline Double Blue - Tmux Theme
# Created by Jim Myhrberg <contact@jimeh.me>.
#
# Inspired by vim-powerline: https://github.com/Lokaltog/powerline
#
# Requires terminal to be using a powerline compatible font, find one here:
# https://github.com/Lokaltog/powerline-fonts
#
# Original code form https://github.com/jimeh/tmux-themepack/blob/1.0.0/powerline/double/blue.tmuxtheme
# This has now been modufied to set color styles for tmux >= 2.9 ish
# Status update interval
set -g status-interval 1
# Basic status bar colors
set -g status-fg colour238
set -g status-bg colour233
# Left side of status bar
set -g status-left-style bg=colour233,fg=colour243
set -g status-left-length 40
set -g status-left "#[fg=colour232,bg=colour24,bold] #S #[fg=colour24,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]"
# Right side of status bar
set -g status-right-style bg=colour233,fg=colour243
set -g status-right-length 150
set -g status-right "#[fg=colour235,bg=colour233]#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour24,bg=colour240]#[fg=colour232,bg=colour24,bold] #H "
# Window status
set -g window-status-format " #I:#W#F "
set -g window-status-current-format "#[fg=colour233,bg=black]#[fg=colour33,nobold] #I:#W#F #[fg=colour233,bg=black,nobold]"
# Current window status
set -g window-status-current-style bg=colour24,fg=colour233
# Window with activity status
set -g window-status-activity-style fg=colour233,bg=colour245 # fg and bg are flipped here due to a bug in tmux
# Highlight active window.
#set -w -g window-status-current-bg red
set -g window-style 'bg=colour18'
set -g window-active-style 'bg=colour0'
# Window separator
set -g window-status-separator ""
# Window status alignment
set -g status-justify centre
# Pane border
set -g pane-border-style bg=default,fg=colour238
# Active pane border
set -g pane-active-border-style bg=default,fg=colour24
# Pane number indicator
set -g display-panes-colour colour233
set -g display-panes-active-colour colour245
# Clock mode
set -g clock-mode-colour colour24
set -g clock-mode-style 24
# Message
set -g message-style bg=colour24,fg=black
# Command message
set -g message-command-style bg=colour233,fg=black
# Mode
set -g mode-style bg=colour24,fg=colour231