vim/config/tmux.conf
Jason 4ec9719a1c
🦈🏠🐜 Initial Commit 🐜🦈🏠
2022-07-06 07:07:00 -04:00

241 lines
9.0 KiB
Bash

# Override LC and LANG
set-environment -g LANG 'en_US.UTF-8'
set-environment -g LC_ALL 'en_US.UTF-8'
set-environment -g LC_CTYPE 'en_US.UTF-8'
# plugins
set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.local/share/tmux/plugins'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'jabirali/tmux-tilish'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'christoomey/tmux-navigator'
set -g @plugin 'kristijanhusak/tmux-simple-git-status'
set -g @plugin 'chriszarate/tmux-tasks'
# Set the prefix to Ctrl+a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# nested tmux, obey me
bind-key a send-prefix
# set default shell
set -g default-command bash
# set theme
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
set-option -g mode-style "fg=default,bg=$color_main"
set-option -g message-style "fg=$color_main,bg=$color_dark"
# All kind of nice options
set-option -g default-terminal "screen-256color"
set-option -g history-limit 100000
set-option -g repeat-time 500
set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'
set-option -ga terminal-overrides ',xterm*:smcup@:rmcup@'
set-option -g base-index 1
set-option -g update-environment -r
# titles
set-option -g set-titles on
set-option -g set-titles-string "#T"
# Window options
set-option -g allow-rename on
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-window-option -g renumber-windows on
set-window-option -g monitor-activity on
set-window-option -g xterm-keys on
set-window-option -g automatic-rename on
set-window-option -g aggressive-resize off
set-window-option -g pane-base-index 1
# Remap keys to my settings
unbind-key d ; bind-key d detach-client
unbind-key Tab ; bind-key Tab choose-window
unbind-key t ; bind-key t new-window
unbind-key ` ; bind-key ` last-window
unbind-key n ; bind-key n next-window
unbind-key p ; bind-key p previous-window
#unbind-key , ; bind-key , rename-window
# Window selection
unbind-key 1 ; bind-key 1 select-window -t 1
unbind-key 2 ; bind-key 2 select-window -t 2
unbind-key 3 ; bind-key 3 select-window -t 3
unbind-key 4 ; bind-key 4 select-window -t 4
unbind-key 5 ; bind-key 5 select-window -t 5
unbind-key 6 ; bind-key 6 select-window -t 6
unbind-key 7 ; bind-key 7 select-window -t 7
unbind-key 8 ; bind-key 8 select-window -t 8
unbind-key 9 ; bind-key 9 select-window -t 9
# Window splitting
unbind-key \ ; bind-key \ split-window -c "#{pane_current_path}" -h
unbind-key / ; bind-key / split-window -c "#{pane_current_path}" -v
# Pane selection and resizing
unbind-key left ; bind-key left select-pane -L
unbind-key up ; bind-key up select-pane -U
unbind-key down ; bind-key down select-pane -D
unbind-key right ; bind-key right select-pane -R
unbind-key C-h ; bind-key C-h select-pane -L
unbind-key C-k ; bind-key C-k select-pane -U
unbind-key C-j ; bind-key C-j select-pane -D
unbind-key C-l ; bind-key C-l select-pane -R
unbind-key j ; bind-key -r j resize-pane -D 5
unbind-key k ; bind-key -r k resize-pane -U 5
unbind-key h ; bind-key -r h resize-pane -L 5
unbind-key l ; bind-key -r l resize-pane -R 5
unbind-key C-left ; bind-key -r C-left resize-pane -L 1
unbind-key C-right ; bind-key -r C-right resize-pane -R 1
unbind-key C-up ; bind-key -r C-up resize-pane -U 1
unbind-key C-down ; bind-key -r C-down resize-pane -D 1
unbind-key @ ; bind-key @ confirm-before kill-window
unbind-key ? ; bind-key ? list-keys
# Set that stupid Esc-Wait off, so VI works again
set-option -sg escape-time 0
# set mode either vi or emacs
set-window-option -g mode-keys emacs
# Source setup file
bind-key r source-file ~/.tmux.conf \; display-message 'source ~/.tmux.conf'
bind-key C-r source-file ~/.tmux.conf \; display-message 'source ~/.tmux.conf'
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# system clipboard
#bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
#bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
# copy/paste
set-option -g @copy_use_osc52_fallback on
# mouse support
set-window-option -g mouse on
unbind-key m ; bind-key m run "mouse-toggle"
# Select layout
bind-key w command-prompt -p "tiled/even-horizontal/even-vertical/main-horizontal/main-vertical?" "select-layout '%%'"
# Zoom tmux pane with '+' key
bind + resize-pane -Z
# Message display time (ms)
set-option -g display-time 2000
# Notification
set-window-option -g monitor-activity on
set-option -g visual-activity on
set-option -g bell-action any
set-option -g visual-bell on
# Plugin properties
set -g @tilish-navigate 'on'
set -g @sidebar-tree 't'
set -g @sidebar-tree-focus 'T'
set -g @sidebar-tree-command 'tree -C'
set -g @sidebar-tree-position 'right'
## tmux prefix highlight
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_prefix_prompt 'PRE'
set -g @prefix_highlight_copy_prompt 'COPY'
set -g @prefix_highlight_sync_prompt 'SYNC'
set -g @prefix_highlight_empty_prompt 'TMUX'
# tmux continuum
set -g @continuum-restore 'on'
set -g @continuum-save-interval '5'
# tmux resurrect
set -g @resurrect-dir '~/.cache/resurrect'
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
set -g @resurrect-hook-post-save-all 'eval $(xdotool getwindowgeometry --shell $WINDOWID); echo 0,$X,$Y,$WIDTH,$HEIGHT > ~/.cache/resurrect/geometry'
set -g @resurrect-hook-pre-restore-all 'wmctrl -i -r $WINDOWID -e $(cat ~/.cache/resurrect/geometry)'
# Task manager
set -g @tasks_manager 'taskwarrior'
set -g @tasks_format_begin '#[fg=orange,bg=#f8f8f2]'
set -g @tasks_format_end '#[fg=white,bg=#44475a]'
set -g @tasks_icon_urgent '🔥'
set -g @tasks_icon_outstanding '+'
# 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)?$'"
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'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
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
bind-key -T copy-mode-vi 'C-\' select-pane -l
# general status bar settings
set-option -g status on
set-option -g status-interval 2
set-option -g status-position "bottom"
set-option -g status-justify "centre"
set-option -g status-left-length 120
set-option -g status-right-length 120
set -g status-style "fg=$color_status_text,bg=$color_dark"
set -g window-status-separator ''
set -g status-left ' #{prefix_highlight} | Sess:#S | #(whoami)@#H | #{tasks_status} |#{simple_git_status}'
set -g status-right '#(echo -n "$(weather)" | Continuum: #{continuum_status} | %a %m/%d %H:%M '
set -g window-status-format ' #I:#W '
set -g window-status-current-format ' #W '
setw -g window-status-activity-style "fg=$color_main"
setw -g window-status-current-style "fg=$color_light,bold,bg=$color_main"
# import user config
if '[ -f ~/.tmux.local ]' 'source ~/.tmux.local'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
if "test ! -d ~/.local/share/tmux/tpm/.git" "run '/usr/local/bin/tmux-plugins'"
if "test -f ~/.local/share/tmux/tpm/tpm" "run '~/usr/local/bin/tmux-plugins'"