This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/apps/shell/tmux/conf

169 lines
5.0 KiB
Plaintext
Raw Normal View History

2017-02-07 16:16:45 -06:00
# ^s as prefix
unbind C-b
set -g prefix C-s
bind-key s send-prefix
2019-08-09 10:00:52 -05:00
# reload tmux.conf
2020-01-20 11:40:26 -06:00
bind-key T source-file "$HOME/.tmux.conf" \; display-message "source-file done"
2019-08-09 10:00:52 -05:00
unbind r
2020-01-20 11:40:26 -06:00
bind r source-file "$HOME/.tmux.conf"
2019-08-06 12:33:23 -05:00
2020-03-06 15:44:26 -06:00
# set -as terminal-overrides ",xterm*:smxx=\E[9m"
2020-01-20 12:43:55 -06:00
set -g default-terminal "screen-256color"
2019-12-13 11:32:15 -06:00
2019-08-09 10:00:52 -05:00
# sane defaults
2020-01-20 09:12:52 -06:00
set -g mouse on
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# honestly not exactly sure?
2019-11-17 09:06:44 -06:00
# set -sg escape-time 1
2020-01-20 09:12:52 -06:00
set -g escape-time 0
2019-08-09 10:00:52 -05:00
# show window activity
2020-01-20 12:32:23 -06:00
# TODO: this needs to be properly setup - presumably with tmux-session-list
2020-01-20 09:12:52 -06:00
setw -g monitor-activity on
setw -g visual-bell on
setw -g bell-action other
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# common window sizes
2017-02-07 16:16:45 -06:00
bind-key W resize-pane -x 100
2019-08-09 10:00:52 -05:00
bind-key f resize-pane -x 120
bind-key F resize-pane -x 125
bind-key 8 resize-pane -x 80
bind-key 2 resize-pane -y 20
2017-02-07 16:16:45 -06:00
# splitting
bind-key v split-window -h
bind-key b split-window
2019-08-09 10:00:52 -05:00
bind-key h split-window
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# show tmux status bar by default with (C-s, H) to toggle it
set -g status on
2020-01-20 09:12:52 -06:00
set -g history-limit 102400000
2019-08-13 16:18:27 -05:00
bind-key H set -s status
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# simple session switching
bind-key j switch-client -p
bind-key h switch-client -p
bind-key k switch-client -n
bind-key l switch-client -n
2020-03-06 15:44:26 -06:00
# bind s run-shell "tmux new-window sh -c "$DOTFILES_PATH/bin/tmuxswitcher""
2020-11-06 00:31:43 -06:00
bind s run-shell "tmux new-window \"sh -c ~/.config/lytedev-dotfiles/bin/tmuxswitcher\""
2018-06-05 11:05:20 -05:00
2019-08-09 10:00:52 -05:00
# reset the working directory of the current session
2020-03-06 15:44:26 -06:00
bind-key P attach-session -t . -c "#{pane_current_path}" \; display-message "Reset session dir to #{pane_current_path}"
2017-04-23 06:47:00 -05:00
2019-08-09 10:00:52 -05:00
# status bar and messages
2020-01-20 09:12:52 -06:00
set -g status-position bottom
set -g status-bg colour0
set -g status-fg colour8
set -g status-interval 5
set -g status-right-length 80
2019-03-25 10:56:41 -05:00
set -g status-right "#[fg=colour4]#W#[fg=default]#[bg=default] #H"
set -g status-left-length 200
2020-11-06 00:31:43 -06:00
set -g status-left "#[fg=colour7]#(~/.config/lytedev-dotfiles/bin/tmux-session-list #S)"
2020-03-06 15:44:26 -06:00
set -g message-style "fg=colour7 bg=colour18"
2020-11-06 00:31:43 -06:00
bind-key O display-message "#(~/.config/lytedev-dotfiles/bin/tmux-save-buffer #S)"
2019-08-23 09:45:26 -05:00
2019-08-09 10:00:52 -05:00
# pane split line colors
2019-11-28 08:22:41 -06:00
set -g pane-active-border-style bg=black,fg=blue
set -g pane-border-style bg=black,fg=colour18
2019-08-09 10:00:52 -05:00
# cLocK mOdE Is sUpEr 3LeEt
set -g clock-mode-colour colour8
# windows (which I don't use much...?)
# TODO: do I have a use case for windows?
2020-03-06 15:44:26 -06:00
setw -g window-status-current-format ""
2019-08-09 10:00:52 -05:00
2017-02-07 16:16:45 -06:00
# vim copying
2020-01-20 09:12:52 -06:00
setw -g mode-keys vi
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# 1-based indexing for key binding simplicity
2017-02-07 16:16:45 -06:00
set -g base-index 1
set -g pane-base-index 1
# custom predefined layouts
2020-03-06 15:44:26 -06:00
bind M-l source-file "$XDG_CONFIG_HOME/tmux/layouts/dev.tmux"
2017-02-07 16:16:45 -06:00
# present a menu of urls to open from the visible pane
2019-08-09 10:00:52 -05:00
# TODO: fzf-ify this
2017-02-07 16:16:45 -06:00
bind-key u capture-pane \;\
save-buffer /tmp/tmux-buffer \;\
2019-08-09 10:00:52 -05:00
split-window -l 10 "urlscan /tmp/tmux-buffer"
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# seamlessly handle pane switching in and out of vim panes
# see GitHub repos tmux-plugins/vim-tmux-focus-events and christoomey/vim-tmux-navigator
2020-03-06 15:44:26 -06:00
is_vim="ps -o state= -o comm= -t \"#{pane_tty}\" \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
2019-08-09 10:00:52 -05:00
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
2020-04-21 16:38:58 -05:00
bind-key -T copy-mode-vi "C-h" send -X "cancel select-pane -L"
2019-08-09 10:00:52 -05:00
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"
# not sure about this binding? possibly switch to previous pane...?
2018-06-05 11:05:20 -05:00
# bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
2017-04-28 21:43:23 -05:00
2019-08-09 10:00:52 -05:00
# YANKING
2020-04-21 16:38:58 -05:00
# bind-key -T copy-mode-vi "y" send -X copy-selection
bind-key -T copy-mode-vi "y" send-keys -X copy-pipe-and-cancel -X 'clip'
2020-03-06 15:44:26 -06:00
2020-07-09 17:40:10 -05:00
# various control binds
bind-key n command-prompt -p "New Session:" "new-session -s '%1'"
bind-key K kill-pane
bind-key C-S-k kill-session -C
2020-03-06 15:44:26 -06:00
set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/.config/tmux/plugins/"
2017-04-28 21:43:23 -05:00
2017-02-07 16:16:45 -06:00
# list of plugins
2020-03-06 15:44:26 -06:00
set -g @plugin "tmux-plugins/tpm"
set -g @plugin "tmux-plugins/tmux-sensible"
set -g @plugin "lytedev/tmux-resurrect"
set -g @plugin "lytedev/tmux-continuum"
2017-11-13 15:57:25 -06:00
# prefix+[ for select mode
# v for visual mode
# yank to clipboard with y
# paste with prefix+]
2020-03-06 15:44:26 -06:00
set -g @plugin "tmux-plugins/tmux-yank"
2020-03-06 15:44:26 -06:00
set -g @plugin "tmux-plugins/tmux-copycat"
set -g @plugin "tmux-plugins/tmux-sessionist"
set -g @plugin "christoomey/vim-tmux-navigator"
2017-02-07 16:16:45 -06:00
# plugin options
# enable continuum
2020-03-06 15:44:26 -06:00
set -g @continuum-restore "on"
2017-02-07 16:16:45 -06:00
# let continuum startup on boot
2020-05-18 15:34:35 -05:00
# NOTE: disabled this due to it starting up before sway socket is up and then
# sway commands do not work from within tmux
# TODO: maybe sway (or any wm) can start continuum?
# set -g @continuum-boot "on"
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# bindings for tmux-resurrect
2020-03-06 15:44:26 -06:00
set -g @resurrect-save "C-v"
set -g @resurrect-restore "R"
2017-02-07 16:16:45 -06:00
# initialize tmux plugin manager
2020-03-06 15:44:26 -06:00
run "~/.config/tmux/plugins/tpm/tpm"
2017-02-07 16:16:45 -06:00
2019-08-09 10:00:52 -05:00
# attempt at integrating nested tmux sessions nicely
2020-01-20 09:12:52 -06:00
# bind -T root F12 \
# set prefix None \;\
# set key-table off \;\
# set status off \
2020-03-06 15:44:26 -06:00
# if -F "#{pane_in_mode}" "send-keys -X cancel" \;\
2020-01-20 09:12:52 -06:00
# refresh-client -S \;\
# bind -T off F12 \
# set -u prefix \;\
# set -u key-table \;\
# set status on \;\
# refresh-client -S
2019-07-02 11:47:13 -05:00
2017-02-07 16:16:45 -06:00
unbind-key C-p
2020-04-09 22:09:00 -05:00
set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t 0'