-
-
Save useraccessdenied/e35dfef77c86c82162b1b42966c72729 to your computer and use it in GitHub Desktop.
my tmux config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detect the correct TERM value for new sessions. | |
# if-shell uses /bin/sh, so bashisms like [[ do not work. | |
if "[ $(tput colors) = 16777216 ]" { | |
set -g default-terminal "tmux-direct" | |
} { | |
if "[ $(tput colors) = 256 ]" { | |
set -g default-terminal "tmux-256color" | |
} { | |
set -g default-terminal "tmux" | |
} | |
} | |
# I use Emacs keybindings. | |
setw -g mode-keys emacs | |
# More terminal insanity. There's no correct value, but the | |
# half-second default adds noticeably latency. | |
# https://unix.stackexchange.com/a/608179/459183 | |
# | |
# mintty uses an alternate, unambiguous keycode: | |
# https://github.com/mintty/mintty/wiki/CtrlSeqs#escape-keycode | |
set -s escape-time 200 | |
# I can afford 50 MB of scrollback. | |
# Measured on WSL 1 with: | |
# yes $(python3 -c "print('y' * 80)") | |
set -g history-limit 100000 | |
# When multiple clients are connected to a session, only resize | |
# windows to the smaller terminal's size if both clients are looking | |
# at the same window. | |
setw -g aggressive-resize on | |
# Forward window titles to the parent terminal, but only hostname and | |
# process. | |
set -g set-titles on | |
set -g set-titles-string "#h: #W" | |
# When there is activity in a window, set the window active flag, | |
# which gives a small visual indicator in the status line. But disable | |
# any messages or dings, by default. | |
set -g monitor-activity on | |
set -g activity-action none | |
# Make tmux "tabs" (called windows in tmux) work like iTerm2 and web | |
# browsers. | |
# | |
# Every other terminal counts from 1. Now the window numbers match the | |
# order of the numeric keys on a keyboard. | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
# Automatically renumber when they're created, closed, or moved, so | |
# that the window number always matches its index. | |
setw -g renumber-windows on | |
# My tmux muscle memory still wants C-b 0 to select the first window. | |
bind 0 select-window -t ":^" | |
# Other terminals and web browsers use 9 to focus the final tab. | |
bind 9 select-window -t ":$" | |
# Match iTerm2 by binding Alt-Number to the corresponding window. This | |
# does not conflict with any programs I use. Graphical UIs tend to | |
# either ignore M-0 or have it select the last tab. | |
bind -n "M-0" select-window -t ":^" | |
bind -n "M-1" select-window -t ":1" | |
bind -n "M-2" select-window -t ":2" | |
bind -n "M-3" select-window -t ":3" | |
bind -n "M-4" select-window -t ":4" | |
bind -n "M-5" select-window -t ":5" | |
bind -n "M-6" select-window -t ":6" | |
bind -n "M-7" select-window -t ":7" | |
bind -n "M-8" select-window -t ":8" | |
bind -n "M-9" select-window -t ":$" | |
# Match iTerm2's keybindings for selecting previous and next windows. | |
bind -n "M-{" previous-window | |
bind -n "M-}" next-window | |
# "C-b c" adds a window at the end. Have "C-b C-c" add a window after | |
# the current one. | |
bind "C-c" new-window -a | |
# I rarely remember how to move windows around, so add some slightly | |
# more convenient bindings. | |
bind "S-Left" { | |
swap-window -t -1 | |
select-window -t -1 | |
} | |
bind "S-Right" { | |
swap-window -t +1 | |
select-window -t +1 | |
} | |
# Additional key bindings. | |
# Incrementally searching backwards in the scrollback is one of the | |
# most common actions. Give it a dedicated keybinding. This turns | |
# "C-b [ C-r" into "C-b r". | |
bind r { | |
copy-mode | |
command-prompt -i -p "(search up)" \ | |
"send-keys -X search-backward-incremental '%%%'" | |
} | |
# Toggle terminal mouse support. | |
bind m set-option -g mouse \; display "Mouse: #{?mouse,ON,OFF}" | |
# Toggle status bar. Useful for focusing in fullscreen mode. See Emacs | |
# writeroom-mode. | |
bind t set-option status | |
# Improve the status bar. The default status bar places the session ID | |
# to the left, but I rarely have more than one session. I do, however, | |
# care about the hostname, so hostname:session_id followed by month, | |
# day, and current time is useful context for the lower right. | |
set -g status-left " " | |
set -g status-right-length 60 | |
set -g status-right " #h:#S %b %d %H:%M " | |
# If we support at least 256 colors, give the tmux status bar a nice | |
# amber glow, reminiscent of old amber phosphor CRTs. Also, render the | |
# active window with a slightly brighter background, so it stands out | |
# clearly. | |
if "[ $(tput colors) -ge 256 ]" { | |
set -g status-left-style "fg=black bg=colour130" | |
set -g status-right-style "bg=colour17 fg=orange" | |
set -g status-style "fg=black bg=colour130" | |
set -g message-style "fg=black bg=colour172" | |
# Current window should be slightly brighter. | |
set -g window-status-current-style "fg=black bg=colour172" | |
# Windows with activity should be very subtly highlighted. | |
set -g window-status-activity-style "fg=colour17 bg=colour130" | |
set -g mode-style "fg=black bg=colour172" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment