You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
6.2 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# To not fuck everything up when Im using Vim, use a pretty short Escape time for Alt shortcuts.
set -g escape-time 20
# Start numbering windows with the leftmost key on the keyboard and allow renumbering.
set -g base-index 1
set -g renumber-windows on
# 64k (lines, that is) of history ought to be enough for everyone.
set -g history-limit 64000
# Enable mouse.
set -g mouse on
# Allow the Linux framebuffer console to send xterm-1006 style mouse events.
# This is required for tmux to react to conmaus <https://codeberg.org/scy/conmaus>.
set -g terminal-overrides linux:kmous=\e[<
# If the outer terminal is signalling true color support, define an override, because its terminfo file might not know
# about this. This is for example the case in MS Terminal, which defines itself as xterm-256color.
if-shell '[ "$COLORTERM" = "24bit" -o "$COLORTERM" = "truecolor" ]' "set -g terminal-overrides ',xterm*:Tc'"
# When multiple clients are connected to the same session, determine the size of windows depending on where they are
# _displayed_, not where they are attached to. This allows for different screen sizes inside of the same session
# group, as long as the clients are looking at different windows each.
set -g aggressive-resize on
# When a client detaches, clean up leftover sessions in the "main" group.
# (I don't check whether the client actually had been attached to that group.)
# Note that this hook may not work when closing the terminal (or signals in general) on tmux < 2.7, see
# <https://github.com/tmux/tmux/commit/19f3a5c6120c5d845eb942e67413c03c0c008a87>.
set-hook -g client-detached "run-shell ~/.tmux/kill-leftovers-in-group.sh"
# Nowadays, I have (at least) 256-color terminals everywhere, and also a real "tmux" terminfo. Compared to
# `screen-256color`, this has the added advantage of italic text working (instead of displayed with reversed colors).
set -g default-terminal tmux-256color
# However, there is one terminal where I don't really have 256 colors: The Linux Console.
if-shell '[ "$TERM" = "linux" ]' "set -g default-terminal tmux"
# Default colors.
set -g pane-border-style fg=brightblack
set -g pane-active-border-style fg=brightgreen
# Name windows automatically by their current pane. If the pane has a terminal title set, use that. If not, the current
# command running in the pane.
set -g automatic-rename on
set -g automatic-rename-format "#{?pane_title,#{pane_title},#{pane_current_command}}"
# Also set that name as the terminal emulator's title.
set -g set-titles on
set -g set-titles-string "#{?pane_title,#{pane_title},#{pane_current_command}}"
# Make the status line a lot more stylish.
# TODO: These require a powerline-compatible font. A fallback would be nice.
set -g status-interval 1
set -g status-justify centre
# With the decorations, the default of 10 characters can be too short.
set -g status-left-length 12
set -g status-right "#[fg=white,bg=default] #[fg=black,bg=white,bold]#h#[nobold] %Y-%m-%d %H:%M:%S#[fg=white,bg=default]"
set -g status-style "bg=default,fg=white"
set -g window-status-style "bg=default,fg=white"
set -g window-status-format "#{?window_zoomed_flag,⌈,} #I #W #{?window_zoomed_flag,⌋,}"
set -g window-status-separator " "
set -g window-status-current-style "fg=brightwhite"
set -g window-status-activity-style "bg=default,fg=brightyellow"
set -g window-status-bell-style "bg=default,fg=brightred"
set -g window-status-last-style "bg=default,fg=blue"
set -g window-status-current-format "#[fg=blue,bg=default]#{?window_zoomed_flag, ,}#[fg=default,bg=blue,bold] #I #[nobold] #W #[fg=blue,bg=default]#{?window_zoomed_flag, ,}"
# Give a visual indication by changing the color to blue when the prefix key has been pressed.
# When changing this, don't forget that there's a copy in .tmux.nested.conf that needs to be updated, too.
set -g status-left "#{?client_prefix,#[fg=blue]#[bg=default]#[fg=brightwhite]#[bg=blue]#S#[fg=blue]#[bg=default],#[fg=white]#[bg=default]#[fg=black]#[bg=white]#S#[fg=white]#[bg=default]} "
# Since the status line is individual "floating" elements with no continuous background, a colored background when
# entering a command looks strange. However, since this style is _also_ used for messages, and I want these to really
# stand out, I don't see any options right now.
set -g message-style "bg=blue,fg=brightwhite"
# For locking a session I'm using my vlock wrapper.
set -g lock-command vlock-with-blank
# ^Z is just way easier to type than ^B.
# ^A isnt really an alternative for me since I use it often to go to the beginning of the line.
set -g prefix C-Z
# By default, ^Z ^Z suspends the client. I dont need that, but I need to be able to send ^Z to the shell.
bind C-Z send-prefix
# On the machine I'm physicially sitting in front of, I usually run tmux inside of my terminal emulator. When I ssh
# into another machine, I'll likely use a nested tmux session there, too. Therefore, when tmux is launched inside of
# an ssh session, configure some things in a different way.
if-shell '[ -n "$SSH_CONNECTION" ]' "source-file ~/.tmux.nested.conf"
# New shells.
bind -n M-s split-window -v
bind -n M-S split-window -h
bind -n M-c new-window
# Moving around between windows.
bind -n M-, select-window -p
bind -n M-. select-window -n
bind -n M-0 select-window -t :0
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 :9
# Moving around between panes.
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Moving panes around.
bind -n M-H swap-pane -d -t "{left-of}"
bind -n M-J swap-pane -d -t "{down-of}"
bind -n M-K swap-pane -d -t "{up-of}"
bind -n M-L swap-pane -d -t "{right-of}"
# Changing pane layout.
bind -n M-f resize-pane -Z
bind C-e select-layout even-vertical
bind C-w select-layout even-horizontal
bind -r C-h resize-pane -L
bind -r C-j resize-pane -D
bind -r C-k resize-pane -U
bind -r C-l resize-pane -R
# Assorted key bindings.
bind -n M-/ copy-mode
bind = setw synchronize-panes
bind C-d detach
bind C-M-d kill-session
bind C-x lock-client