My vim configuration
git clone https://github.com/m-col/vim-misc
Files | Refs | Readme

-rw-r--r-- tmux.conf


      1 # tmux.conf
      2 
      3 # make C-a prefix
      4 unbind C-b
      5 set -g prefix C-s
      6 bind C-s send-prefix
      7 
      8 # bindings
      9 #bind r source-file ~/.tmux.conf
     10 bind C-l send-keys 'C-l'
     11 bind C-a send-keys 'C-a'
     12 bind | splitw -hb -c '#{pane_current_path}'
     13 bind '"' splitw -c '#{pane_current_path}'
     14 
     15 # general settings
     16 #set -g default-terminal "rxvt-unicode-256color"
     17 #set -g default-terminal "xterm-256color"
     18 set -g default-terminal "tmux-256color"
     19 set -ag terminal-overrides ",xterm-256color:RGB"
     20 set -g mouse on
     21 set -g history-limit 5000
     22 set -s escape-time 0
     23 set -g base-index 1
     24 set -g status off
     25 set -g set-titles on
     26 set -g set-titles-string "[tmux] #T"
     27 set-window-option -g mode-keys vi
     28 
     29 # Intelligently navigate tmux panes and Vim splits using the same keys.
     30 # See https://sunaku.github.io/tmux-select-pane.html for documentation.
     31 #
     32 #      +-------------+------------+-----------------------------+
     33 #      | inside Vim? | is Zoomed? | Action taken by key binding |
     34 #      +-------------+------------+-----------------------------+
     35 #      | No          | No         | Focus directional tmux pane |
     36 #      | No          | Yes        | Nothing: ignore key binding |
     37 #      | Yes         | No         | Seamlessly focus Vim / tmux |
     38 #      | Yes         | Yes        | Focus directional Vim split |
     39 #      +-------------+------------+-----------------------------+
     40 #
     41 vim_navigation_timeout=0.05 # number of seconds we give Vim to navigate
     42 navigate='                                                             \
     43   pane_is_zoomed() {                                                   \
     44     test #{window_zoomed_flag} -eq 1;                                  \
     45   };                                                                   \
     46   pane_title_changed() {                                               \
     47     test "#{pane_title}" != "$(tmux display -p "##{pane_title}")";     \
     48   };                                                                   \
     49   command_is_vim() {                                                   \
     50     case "${1%% *}" in                                                 \
     51       (vi|?vi|vim*|?vim*|view|?view|vi??*) true ;;                     \
     52       (*) false ;;                                                     \
     53     esac;                                                              \
     54   };                                                                   \
     55   pane_contains_vim() {                                                \
     56     case "#{=3:pane_current_command}" in                               \
     57       (ssh|sh) command_is_vim "#{=5:pane_title}" ;;                    \
     58       (*) command_is_vim "#{=5:pane_current_command}" ;;               \
     59     esac;                                                              \
     60   };                                                                   \
     61   pane_contains_neovim_terminal() {                                    \
     62     test "#{=12:pane_title}" = "nvim term://";                         \
     63   };                                                                   \
     64   navigate() {                                                         \
     65     tmux_navigation_command=$1;                                        \
     66     vim_navigation_command=$2;                                         \
     67     vim_navigation_only_if=${3:-true};                                 \
     68     if pane_contains_vim && eval "$vim_navigation_only_if"; then       \
     69       if pane_contains_neovim_terminal; then                           \
     70         tmux send-keys C-\\ C-n;                                       \
     71       fi;                                                              \
     72       eval "$vim_navigation_command";                                  \
     73       if ! pane_is_zoomed; then                                        \
     74         sleep $vim_navigation_timeout; : wait for Vim to change title; \
     75         if ! pane_title_changed; then                                  \
     76           eval "$tmux_navigation_command";                             \
     77         fi;                                                            \
     78       fi;                                                              \
     79     elif ! pane_is_zoomed; then                                        \
     80       eval "$tmux_navigation_command";                                 \
     81     fi;                                                                \
     82   };                                                                   \
     83 navigate '
     84 navigate_left=" $navigate 'tmux select-pane -L'  'tmux send-keys C-w h'"
     85 navigate_down=" $navigate 'tmux select-pane -D'  'tmux send-keys C-w j'"
     86 navigate_up="   $navigate 'tmux select-pane -U'  'tmux send-keys C-w k'"
     87 navigate_right="$navigate 'tmux select-pane -R'  'tmux send-keys C-w l'"
     88 navigate_back=" $navigate 'tmux select-pane -l || tmux select-pane -t1'\
     89                           'tmux send-keys C-w p'                       \
     90                           'pane_is_zoomed'                             "
     91 
     92 bind-key -n C-h run-shell -b "$navigate_left"
     93 bind-key -n C-j run-shell -b "$navigate_down"
     94 bind-key -n C-k run-shell -b "$navigate_up"
     95 bind-key -n C-l run-shell -b "$navigate_right"
     96 
     97 bind g command-prompt -p "title:" 'run-shell "/Users/matt/.zsh/new-cc-session.sh %1"'
     98