Skip to content

Instantly share code, notes, and snippets.

@mmm
Last active July 31, 2024 19:04
Show Gist options
  • Save mmm/3879853 to your computer and use it in GitHub Desktop.
Save mmm/3879853 to your computer and use it in GitHub Desktop.
tmux config
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
# START:prefix
set -g prefix C-a
set -g prefix2 C-b
# END:prefix
# Free the original Ctrl-b prefix keybinding
# START:unbind
#unbind C-b
# END:unbind
#setting the delay between prefix and command
# START:delay
set -sg escape-time 0
# END:delay
# Ensure that we can send Ctrl-A to other apps
# START:bind_prefix
bind C-a send-prefix
# END:bind_prefix
# Set the base index for windows to 1 instead of 0
# START:index
set -g base-index 1
# END:index
set -g history-limit 10000
unbind A
bind A command-prompt "rename-window %%"
# Set the base index for panes to 1 instead of 0
# START:panes_index
#setw -g pane-base-index 1
# END:panes_index
# Reload the file with Prefix r
# START:reload
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
# END:reload
# splitting panes
# START:panesplit
bind | split-window -h
bind - split-window -v
# END:panesplit
# moving between panes
# START:paneselect
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# END:paneselect
unbind Tab
bind Tab last-pane
unbind BTab
bind BTab last-pane
# Quick pane selection
# START:panetoggle
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# END:panetoggle
# Pane resizing
# START:paneresize
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# END:paneresize
# mouse support - set to on if you want to use the mouse
# START:mouse
# not really sure what this does, but with it, the scrollwheel works inside Vim
#set -g mouse-utf8 off
#set -g mouse
# END:mouse
# Set the default terminal mode to 256color mode
# START:termcolor
set -g default-terminal "screen-256color"
set -as terminal-features ',screen-256color:clipboard'
#
#attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
# termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# # Erase background with current bg color. Not needed if TERM=screen-256color
# defbce "on"
#
# END:termcolor
# enable activity alerts
#START:activity
setw -g monitor-activity on
#set -g visual-activity on
#END:activity
# set the status line's colors
# START:statuscolor
set-option -g status-style bg=default,fg=white
# END:statuscolor
# set the color of the window list
# START:windowstatuscolor
setw -g window-status-style fg=cyan,bg=default,dim
#setw -g window-status-format "#[fg=normal]#I#F$ #W"
setw -g window-status-format "#[fg=normal]#I:#W#F "
# END:windowstatuscolor
# set colors for the active window
# START:activewindowstatuscolor
setw -g window-status-current-style fg=white,bg=default,bright
setw -g window-status-current-format "#[fg=red](#[fg=white]#I:#W#F#[fg=red]) "
# END:activewindowstatuscolor
#setw -g window-status-alert-fg cyan
#setw -g window-status-alert-bg default
#setw -g window-status-alert-attr bright
#setw -g window-status-bell-style fg=cyan,bg=black,bright
#setw -g window-status-activity-style fg=cyan,bg=black,bright
# pane colors
# START:panecolors
#set -g pane-border-fg colour239
#set -g pane-border-bg colour234
#set -g pane-border-bg default
# clean thin lines
#set -g pane-active-border-fg yellow
#set -g pane-active-border-bg defaultk
# thick hilighter lines
#set -g pane-active-border-fg white
#set -g pane-active-border-bg yellow
# END:panecolors
# Command / message line
# START:cmdlinecolors
#set -g message-fg white
#set -g message-bg black
#set -g message-attr bright
# END:cmdlinecolors
# Status line left side
# START:statusleft
set -g status-left-length 40
#set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-left "#[fg=green][#S] #[fg=yellow]#I #[fg=cyan]#P"
# END:statusleft
#START:utf8
#set -g status-utf8 on
#END:utf8
# Status line right side
# 15% | 28 Nov 18:15
# START: statusright
#set -g status-right "#[fg=cyan]%d %b %R"
set -g status-right "#[fg=cyan]#(date -u +'%%F %%R')"
set -g status-right "#[fg=green][ #[fg=cyan]#(date -u +'%%F %%R') #[fg=green]]"
# END:statusright
# Update the status bar every sixty seconds
# START:updateinterval
set -g status-interval 60
# END:updateinterval
# Center the window list
# START:centerwindowlist
set -g status-justify centre
# END:centerwindowlist
# enable vi keys.
# START:vikeys
setw -g mode-keys vi
# bind -T copy-mode-vi v send-keys -X begin-selection
# bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "wl-copy && wl-paste -n | wl-copy -p"
bind-key p run "wl-paste -n | tmux load-buffer - ; tmux paste-buffer"
# END:vikeys
#mmm not sure if this is working or not
#smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
bind C-s set-window-option synchronize-panes
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer'
setw -g xterm-keys on
#run-shell ~/.tmux-sidebar/sidebar.tmux
#set -g @sidebar-tree-command 'tree -C'
#set-option -ag status-right '#{?pane_synchronized, #[bg=blue]SYNC!!!#[default],}'
#set-option -gw window-status-current-format '#{?pane_synchronized,#[fg=blue]***#[default],}#I:#W#F#{?pane_synchronized,#[fg=blue]***#[default],}'
#" #{?pane_synchronized,⛓ , }#W "
#bind -n C-g popup -E "tmux new-session -A -s scratch"
#bind -n C-G popup -E -h 90% -w 9j% "tmux new-session -A -s scratch"
bind -n C-s popup -E "tmux new-session -A -s scratch"
#bind -n C-t popup -E -h 75% "tmux new-session -A -s todo"
#bind -n C-t popup -E -h 75% "notes" # this spawns nothing but nvim... which is probably what I want
bind -n C-t popup -E -h 75% "tmux new-session -A -s today" # could alternatively spawn tmux attached to a session that's running nvim?
# from theprimeagen's setup... https://github.com/ThePrimeagen/.dotfiles/blob/master/tmux/.tmux.conf
#bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/.dotfiles/personal/todo.md"
# forget the find window. That is for chumps
#bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
# bind-key -r i run-shell "tmux neww tmux-cht.sh"
# bind-key -r G run-shell "~/.local/bin/tmux-sessionizer ~/work/nrdp"
# bind-key -r C run-shell "~/.local/bin/tmux-sessionizer ~/work/tvui"
# bind-key -r R run-shell "~/.local/bin/tmux-sessionizer ~/work/milo"
# # bind-key -r L run-shell "~/.local/bin/tmux-sessionizer ~/work/hpack"
# bind-key -r H run-shell "~/.local/bin/tmux-sessionizer ~/personal/vim-with-me"
# bind-key -r T run-shell "~/.local/bin/tmux-sessionizer ~/personal/refactoring.nvim"
# bind-key -r N run-shell "~/.local/bin/tmux-sessionizer ~/personal/harpoon"
# bind-key -r S run-shell "~/.local/bin/tmux-sessionizer ~/personal/developer-productivity"
#
# but...
# he's on dvorak,
# so {GCR} => {UIO}
# bind-key -r U run-shell "~/.local/bin/tmux-sessionizer ~/work/nrdp"
#bind-key -r U tmux switch -t "mail"
# bind-key -r I run-shell "~/.local/bin/tmux-sessionizer ~/work/tvui"
#bind-key -r I run-shell "~/.local/bin/tmux-sessionizer ~/work/tvui"
# bind-key -r O run-shell "~/.local/bin/tmux-sessionizer ~/work/milo"
# and home-row... {HTNS} => {JKL:}
# bind-key -r J run-shell "~/.local/bin/tmux-sessionizer ~/personal/vim-with-me"
# bind-key -r K run-shell "~/.local/bin/tmux-sessionizer ~/personal/refactoring.nvim"
# bind-key -r L run-shell "~/.local/bin/tmux-sessionizer ~/personal/harpoon"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment