Last active
August 14, 2023 05:53
-
-
Save zsimic/03d4ac3cedf40a88f1d5 to your computer and use it in GitHub Desktop.
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
unbind-key -a | |
set -g prefix C-b | |
# Auto scroll with mouse wheel or page up/down, but only if no other process took the screen (such as vi or less) | |
set -g mouse on | |
set -s set-clipboard off | |
bind -n PageUp if-shell -F "#{alternate_on}" "send-keys PageUp" "copy-mode -e; send-keys PageUp" | |
bind -n PageDown if-shell "test #{pane_in_mode} -gt 0 -o #{alternate_on} -gt 0" "send-keys PageDown" | |
bind -n WheelUpPane if-shell -F "#{alternate_on}" "send-keys -M" "select-pane -t= \; copy-mode -e \; send-keys -M" | |
bind -n WheelDownPane if-shell -F "#{alternate_on}" "send-keys -M" "select-pane -t= \; send-keys -M" | |
# Most commonly used combinations | |
bind c new-window -c "#{pane_current_path}" | |
bind d detach-client | |
bind -n M-` last-window | |
bind -n M-Left previous-window | |
bind -n M-Right next-window | |
bind PageUp copy-mode -u | |
# Misc, useful mostly when changing tmux conf | |
bind , command-prompt -I "#W" "rename-window '%%'" | |
bind ':' command-prompt | |
bind ? list-keys | |
bind q display-panes | |
bind r source-file ~/.tmux.conf \; display-message "Reloaded ~/.tmux.conf" | |
bind '~' show-messages | |
bind -n C-S-Insert kill-session -C # Clear alerts | |
bind t clock-mode | |
#bind -n C-S-Home send-keys 'cmatrix -u10' Enter # Just for fun | |
# Pane splitting (I use this very rarely) | |
bind | split-window -h -c "#{pane_current_path}" | |
bind - split-window -v -c "#{pane_current_path}" | |
bind ! break-pane | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D | |
bind -n M-S-Up select-pane -U | |
bind -n M-S-Down select-pane -D | |
bind -n M-S-Left select-pane -L | |
bind -n M-S-Right select-pane -R | |
bind -n C-S-Up resize-pane -U 2 | |
bind -n C-S-Down resize-pane -D 2 | |
bind -n C-S-Left resize-pane -L 2 | |
bind -n C-S-Right resize-pane -R 2 | |
# Settings | |
set -g default-terminal screen-256color | |
set -g history-limit 100000 | |
set -sg escape-time 0 # Do away with esc/alt disambiguation | |
set -g visual-activity off | |
set -g status-keys vi | |
set -g base-index 1 | |
set -g pane-base-index 1 | |
set -g status-interval 60 | |
setw -g alternate-screen on | |
setw -g xterm-keys on | |
set -gw xterm-keys on | |
setw -g mode-keys vi | |
# Minimalist status bar, current window highlighted, all others dim, git branch and uptime on bottom right | |
set -g allow-rename on | |
setw -g automatic-rename off | |
set -g set-titles off | |
setw -g monitor-activity on | |
setw -g aggressive-resize on | |
set -g status-justify left | |
set -g status-style none | |
set -g status-left "" | |
setw -g window-status-format ' #W ' | |
setw -g window-status-current-format '⊣ #W ⊢' | |
setw -g window-status-activity-style fg=red,bright | |
setw -g window-status-style fg=white,dim | |
setw -g window-status-current-style fg=green,bright | |
set -g status-right '#(/usr/bin/python3 ~/bin/shrinky.py tmux_status -p"#{pane_current_path}")' | |
# set -g status-right '#[fg=blue]#(uptime | egrep -o "up ([^,]+)")' | |
set -g status-right-length 30 | |
#set -ga terminal-overrides ',xterm*:smcup@:rmcup@' | |
# Unicode delims: ▏▕ «» ‹› ᚜᚛ ⁅⁆ ⊣⊢ ⸡⸠ |
Starting tmux with a default set of tabs
You can easily start tmux with a predefined set of tabs open, with names and current working directory set... I use this for example:
- in iTerm2 -> Profiles -> your profile -> Send text at start -> /bin/bash ~/bin/start-tmux
- ~/bin/start-tmux example shown below
#!/bin/bash
[ ! -x "$(command -v tmux)" ] && echo "tmux not installed" && exit 1
[ -n "$TMUX" ] && echo "already in tmux" && exit 1
if ! tmux has-session -t main 2>/dev/null; then
tmux new-session -d -s main -n first-window
tmux new-window -n second-window -c ~/
tmux new-window -n third-window -c ~/
fi
tmux attach-session -t main
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my
.tmux.conf
.Guiding principles:
Make mouse work nicely with tmux on macOS:
Install tmux: brew install tmux
I use iTerm2 +
tmux
on macOS, with no UI tabs. It works great, including some nice mouse support.I just start one
tmux
session, and usetmux
windows exclusively. So, I configure iTerm2 in such a way that its own UI stuff get out of the way (at least on the Profile that I use for tmux).This is roughly my setup in iTerm2 -> Preferences:
With a
tmux.conf
similar to mine, you should now be able to scroll using the mouse wheel in tmux (but no scrolling history outside of tmux)