Disclaimer: this is gds' mental model of how tmux with Luan's config works. While they try to use terminology consistent with the rest of the world, they could easily be wrong. Corrections welcome.
Most of the time in tmux, you're in normal mode. When you type things, they go into your shell, and your shell can run them. You can also run the following commands.
C-spc c
-- create a new windowC-spc 1
-- switch to window 1- ...
C-spc 9
-- switch to window 9C-spc C-spc
-- switch to most recent other windowC-spc ,
-- rename this window- To close a window, close all the panes in it. Windows start with one pane. See below.
C-spc |
-- split window vertically (creates a new "pane")C-spc -
-- split window vertically (creates a new "pane")C-spc h
-- switch keyboard focus to the pane to the leftC-spc j
-- switch keyboard focus to the pane belowC-spc k
-- switch keyboard focus to the pane aboveC-spc l
-- switch keyboard focus to the pane to the rightC-spc z
-- Zoom!- If you can see multiple panes, this will "zoom in" on the current pane.
- If you're already "zoomed in", this will zoom out, so you can see multiple panes again.
- Panes are just regular subshells running your usual shell. If you're running
bash
you can close them withexit
orC-d
.
C-spc [
-- enter movement modeC-spc ]
-- paste text that you previously copied in movement mode
Movement mode is like being in vim. You can move around using vim movement keys. You can highlight things. You can copy things to a clipboard, for pasting later (in normal mode).
h
-- go leftj
-- go downk
-- go upl
-- go right0
-- go to the beginning of the line$
-- go to the end of the linew
-- go foreword by one Wordb
-- go Backward by one wordfx
-- go Foreword until you hit the nextx
character. Also works for any other character instead ofx
.Fx
-- go backward until you hit the nextx
character. Also works for any other character instead ofx
.tx
-- go foreword unTil just before you hit the nextx
character. Also works for any other character instead ofx
.Tx
-- go backward unTil just before you hit the nextx
character. Also works for any other character instead ofx
.
/
-- search forwards?
-- search backwardsn
-- jump to the next thing that matches your last search (in whatever direction you were already searching)N
-- jump to the previous thing that matches your last search (in whatever direction you were already searching)
v
-- start highlighting character-by-character (you can continue to highlight by moving around)V
-- start highlighting line-by-line (you can continue to highlight by moving around)y
-- copy whatever is highlighted to the clipboard (so you can paste later in normal mode). This also puts you immediately back into normal mode.
ESC
stop highlighting or searchingq
stop being in movement mode -- go back to normal mode.
I'm in tmux, and I have a single terminal in a single pane in a single window.
I have a list of handy commands in a file called handy-bash-commands.txt
. I
want to use one of them. I'm going to cat the file, copy the appropriate command
to clipboard, paste it into my shell, and see the results of my cool command.
Let's break that into steps:
First I cat the file:
$ cat handy-bash-commands.txt
handy-command 1
handy-command 2
super cool command
sudo super cool command
another command
more stuff
$
Now my cursor is at the shell prompt as I would expect. I hit C-spc [
to get
into movement mode, then hit kkkk0
to move my cursor to the beginning of the
line that reads sudo super cool command
. To highlight the whole line, I hit
V
. To copy it to clipboard, I hit y
. This also kicks me back into normal
mode, with my cursor at the shell prompt again. To paste and run the command, I
hit C-spc ]
. Note that the reason the command runs as soon as I paste is is
because I copied a newline to clipboard when I highlighted and copied the whole
line earlier.
Here's the result:
$ cat handy-bash-commands.txt
handy-command 1
handy-command 2
super cool command
sudo super cool command
another command
more stuff
$ sudo super cool command
SUPER COOL OUTPUT!
$
Now I want to run something similar to handy-command 2
, but with a slight
difference.
My cursor is at the shell prompt as I would expect. I hit C-spc [
to get
into movement mode, then hit ?handy<ENTER>
to move my cursor to the beginning of the
line that reads handy-command 2
. I'm only interested in the beginning of this
command, so I hit v
to start highlighting character-by-character. I hit ww
to highlight the words handy-command
. I hit y
to copy those words to the
clipboard. This also kicks me back into normal mode, with my cursor at the shell
prompt again. To paste the command, I hit C-spc ]
. Because I didn't copy any
newlines, the command doesn't run immediately, and I can edit it.
Here's what my terminal looks like now:
$ cat handy-bash-commands.txt
handy-command 1
handy-command 2
super cool command
sudo super cool command
another command
more stuff
$ sudo super cool command
SUPER COOL OUTPUT!
$ handy-command
Now I'm free to complete the command as I wish, and run it as normal:
$ cat handy-bash-commands.txt
handy-command 1
handy-command 2
super cool command
sudo super cool command
another command
more stuff
$ sudo super cool command
SUPER COOL OUTPUT!
$ handy-command 65537
Wow, that's a really cool number. Are you a big fan of regular polygons?
$