Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Created October 12, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyKochmann/e256a43625f02cd52256b9af812af243 to your computer and use it in GitHub Desktop.
Save CodyKochmann/e256a43625f02cd52256b9af812af243 to your computer and use it in GitHub Desktop.
My personal tmux.conf I like to start with when setting up new systems.
# by: Cody Kochmann
# license: MIT
#
# This is my personal tmux.conf I like to start with when setting up new systems before I tune
# things for the specific monitors I need to work with.
#
# This has been a comfortable "starting point" for ultrawides, pocket laptops (like gpd pocket),
# and even iphones. (yes, I daily drive tmux on my iphone. I win the oddball fight.)
#
#-------------------------------------------------------------------------------------------------
# set default terminal colors
#-------------------------------------------------------------------------------------------------
set -g default-terminal "screen-256color"
#-------------------------------------------------------------------------------------------------
# create a new profile, everything following this
# until the next "new-session" will be configurations
# for `tmux attach -t $PROFILE_NAME`
#-------------------------------------------------------------------------------------------------
new-session -s cody
#-------------------------------------------------------------------------------------------------
# increase history buffer
#-------------------------------------------------------------------------------------------------
set -g history-limit 1000000
#-------------------------------------------------------------------------------------------------
# set the status settings for what shows in the corner
# sometimes you want system metrics, sometimes you just
# want a clock.
#-------------------------------------------------------------------------------------------------
#set-option status-right ""#[fg=green,bg=default,bright]#(tmux-mem-cpu-load)""
set-option status-right '#{=21:pane_title} %Y-%m-%dT%H:%M'
set-option status on
set-option status-position top
set-option status-interval 10
#-------------------------------------------------------------------------------------------------
# configure the default splitter to be even-vertical
#-------------------------------------------------------------------------------------------------
select-layout even-vertical
#-------------------------------------------------------------------------------------------------
# configure what windows will be "auto-generated" when
# you open the session. each `split-window` is a new
# window and the command is what that window starts with
#-------------------------------------------------------------------------------------------------
#split-window -p 80 'watch -t -n 3 pstree'
#split-window -p 70 'htop'
#split-window -p 70 'atop 3'
split-window -p 80 "$SHELL"
split-window -p 70 'watch -t -n 6 pstree -p'
#-------------------------------------------------------------------------------------------------
# use `swap-pane` to rearange the terminals. I like my
# info on top so this moves the second panel running
# pstree to the top.
#-------------------------------------------------------------------------------------------------
swap-pane -s 2 -t 0
#-------------------------------------------------------------------------------------------------
# configure key bindings so tmux fits your muscle memory or is easier to remember.
# here is what my muscle memory wants:
#
# [CTRL + SPACE] | enter "prefix mode" (similar to mac's [CMD+SPACE] for opening finder
# | to quick switch apps)
#
# [CTRL + SPACE][ARROW] | Due to how tmux default lets prefix mode arrowsn avigate windows, the
# | ctrl+space mapping makes navigating panes really easy to remember since
# | in many desktops ctrl+arrow allows you to switch workspaces.
#
# [CTRL + SPACE][|] | split the current window vertically (easy to remember because "|"
# | looks like the up and down bar I want to split the current pane with)
#
# [CTRL + SPACE][-] | split the current window vertically (easy to remember because "-"
# | looks like the horizontal bar I want to split the current pane with)
#
# [CTRL + SPACE][N] | open a new window (easy to remember because thats what browsers do)
#
#-------------------------------------------------------------------------------------------------
# bind CTRL+SPACE to enter "prefix mode"
set-option -g prefix C-Space
# bind | for vertical bar split
bind | split-window -h
# bind - for horizontal bar split
bind - split-window -v
# bind N to new window
bind N new-window
#-------------------------------------------------------------------------------------------------
# [copy mode]
#
# WARBUBG: I do not use copy mode for what it is designed for. IMHO tmux has bigger problems
# "copy mode" can be leveraged to solve. Feel free to scrap this bit if you disagree.
#
# Below is my config for "copy mode". It is highly opinionated and not 100% felt out because I'm
# still experimenting with the concept of misusing it so I can have a nice scrolling ui in tmux.
#
# I dont really use copy mode in tmux.
# - If I need to save something, I save it to a file.
# - If I need to stick that contents in another file, I use `sed`.
# - If I need to save something I cant repeat, I use a script I tossed together that
# "screenshots a TTY to a file".
#
# This has been more than enough for me personally in a 100% tmux environment.
#
# The reason for these workarounds is tmux doesnt have the best "scroll up/scroll down" experience.
# To me, it is more important to be able to scroll through the data dumped to the console than it
# is to try to force feed a way to simulate having a mouse for copy/paste. If you need mouse
# workflows, USE i3!
#
# [CTRL + SPACE][c] | enter "copy mode" (easy to remember since ctrl+c on any other
# | interface means COPY.)
#
# ---------------------------------------------------------
# (in copy mode)
# ---------------------------------------------------------
# [UP_ARROW] | scroll 1 page up
# [DOWN_ARROW] | scroll 1 page down
#
# What this gives me is a quick way to jump into a mode where I can start navigating through
# scrollback using just my arrows. When Im done scrolling around, I just [esc] to exit my
# little scrolling window.
#
#-------------------------------------------------------------------------------------------------
# bind c to copy mode
bind-key -T prefix c copy-mode
# bind arrows to page up and down in copy mode
# since I only copy with mouse or TTY capture
# anyways
bind -T copy-mode Up send-keys -X page-up
bind -T copy-mode Down send-keys -X page-down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment