Skip to content

Instantly share code, notes, and snippets.

@rw3iss
Created March 21, 2026 18:12
Show Gist options
  • Select an option

  • Save rw3iss/e46698d846fc63a4248b9b41cd15d81e to your computer and use it in GitHub Desktop.

Select an option

Save rw3iss/e46698d846fc63a4248b9b41cd15d81e to your computer and use it in GitHub Desktop.
tmux Setup
# ~/.tmux.conf
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on' # Auto restore on tmux server start
set -g mouse on
set-option -g history-limit 5000
run '~/.tmux/plugins/tpm/tpm'

tmux

Use this command to create 'sessions' which can be preserved, and joined by others.

Note the default .tmux.conf should include the 'tmux-resurrect' and 'tmux-continuum' plugins to enable automatic session restoration, when evoking tmux again for the first time on the environment. See .tmux.conf for other configuration details. Mouse-mode is also automatically enabled (can click for pane focus, and drag panes sizes with mouse).

Basic Commands, Sessions:

tmux new -A -s <name> 			# start a new session, giving a name (-A detaches current then joins or creates if it doesn't exist)
tmux a 							# attach to previous session
tmux a -t <session_name>		# attach to session by name

tmux ls 						# list sessions

exit 							# enter at any tmux session window to kill that session

To create a new session from within a running session:

Ctrl+b+: (enter cli mode, see below), then enter: new-session -s <name>

Tmux Hotkey (in a tmux session):

Ctrl + b + <hotkey> # see below

Hotkeys (most used):

Crtl+b + <hotkey below>:

# General Hotkeys:
? 		# see all hotkey bindings
:		# go to tmux 'cli', and enter manual commands (see below)
d       # detach from a session/tmux (exit tmux and go back to cli, but keeps session open)

# Session hotkeys:
s 		# switch to another session
w 		# list sessions and their windows
$ 		# rename session
( 		# previous session
) 		# next session

# Window hotkeys:
<#> 	# go to specific window #
c 		# create a new window
,		# rename window
& 		# close window
n 		# next window
p 		# previous window

# Pane Control hotkeys:
% 		# split window/pane vertically
" 		# split window/pane horizontally
{ 		# move pane left
} 		# move pane right
(arrow) # move pane in direction
space 	# toggle pane layout

Tmux CLI commands (Ctrl+b+: to enter cli):

kill-session -t 0 				# end a specific session by id/name
kill-session -a 				# kill all other sessions except the current
kill-server 					# end all sessions (use 'tmux' to start the server again)

Plugins:

https://medium.com/@hammad.ai/useful-tmux-plugins-which-i-frequently-use-at-work-41a9b46f7bcb

Change pane background color:

ctrl+b + :
select-pane -t:.0 -P 'bg=black'
select-pane -t:.1 -P 'bg=black'
select-pane -t:.2 -P 'bg=black'

Misc helpful:

Restart a closed process or session: fg (unix-specific)

Install tmux on your system:

Fedora

sudo dnf install tmux

Ubuntu / Debian

sudo apt-get tmux

Mac:

brew install tmux

Windows (git bash):

... this gets a little complicated. Google, but I will update with my setup later.

Setup ~/.tmux.conf

Copy the .tmux.conf file in this gist to your home directory. Customize as needed (ie. change history-limit if you have less memory).

Clone the plugins:

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
git clone https://github.com/tmux-plugins/tmux-continuum ~/.tmux/plugins/tmux-continuum
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment