03. Window Management tmux

Not only can you create new panes, but you may also start entirely new windows. This is useful, especially when you're moving onto another part of the project and need more space.

When you start tmux with the tmux command, you're automatically put into a new window. At the bottom of the status bar, you can see the window's ID, along with its name. The asterisk (*) indicates the current window you're in.

Starting tmux for the first time, you're put into a window with ID 0.
Starting tmux for the first time, you're put into a window with ID 0.

7 Commands for Managing Windows

Here are just 7 commands you can use to manage your windows.

1) Creating a New Window

The following keystroke will create a new window:

<Ctrl-b> c

To create two new windows, one with name "work", and the other named "playground," type:

$ tmux new-window -n work
$ tmux new-window -n playground
Create new windows
Create new windows

2) Switching Windows

As mentioned above, the bottom green row, shows all your current open windows. The asterisk * indicates which window you are current working in. To switch to the next or previous windows use:

<Ctrl-b> n
<Ctrl-b> p

Another way to switch windows is through the window number.

<Ctrl-b> <0-9>

If you're more inclined to just use the command line, you may do so with:

$ tmux next-window
$ tmux previous-window
$ tmux last-window

3) Listing Windows

To list windows and select one to switch to:

<Ctrl-b> w

You may also just view which windows are available by typing:

$ tmux list-windows
0: bash- (2 panes) [81x28] [layout 18c6,81x28,0,0[81x11,0,0,0,81x16,0,12,1]] @0
1: bash* (1 panes) [81x28] [layout c2e0,81x28,0,0,3] @2 (active)
An interactive way to select windows.
An interactive way to select windows.

4) Renaming Windows

To rename a window, type the following into the terminal of a window you wish to rename:

$ tmux rename-window play

You may also just type:

<Ctrl-b> ,

5) Searching Windows

If you have too many windows open and can't find the one you need, you may use the following command to open up the find-window feature:

<Ctrl-b> f
If you have too many windows, it may be best to simply search for windows.
If you have too many windows, it may be best to simply search for windows.

With this, you can type just the beginning letters of the window you want to switch to, and tmux will switch to that window right away.

6) Closing Windows

To close a window, use:

<Ctrl-b> &

To kill the current window:

& tmux kill-window

There is just one more level above windows - Sessions - which we'll cover next!

Take your Linux skills to the next level!

Linux for Beginners

Take your Linux skills to the next level! Try Linux & UNIX

Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

$ Check price
24.9924.99Amazon 4.5 logo(101+ reviews)

More Linux & UNIX resources

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Ad