Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

5 Useful Tips for Better Tmux Terminal Sessions
tecmint ^ | 25 February 2019 | Aaron Kili

Posted on 02/26/2019 8:44:10 AM PST by ShadowAce

tmux is a terminal multiplexer similar to GNU screen, which is used to create, access, and control multiple terminal sessions from a single console. It is useful for system administrators for running more than one command-line program at the same time.

One useful feature of tmux is that it can be detached from a screen and continue running in the background, then later reattached. In this regard, it allows SSH sessions to remain active even after disconnecting from the console.

In tmux, a session is a container for individual consoles being managed by tmux. Each session has one or more windows linked to it. And a window fills the entire screen and you may split it into several rectangular panes (either vertically or horizontally), each of which is a separate pseudo terminal.

In this article, we will explain some useful tips for better tmux sessions in Linux.

Configure Terminal to start tmux by default

To configure your terminal to automatically start tmux as default, add the following lines to your ~/.bash_profile shell startup file, just above your aliases section.

if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
    tmux attach -t default || tmux new -s default
fi

Save the file and close it.

Then close and reopen the terminal to start using tmux by default, every time you open a terminal window.

Give Terminal Session Names

tmux gives a default name for sessions, however, sometimes, this name isn’t descriptive enough. You can give a session a name of your choice.

For example if you are working with multiple data centers, you can name sessions like “datacenter1, datacenter2 etc..”.

$ tmux new -s datacenter1
$ tmux new -s datacenter2

Switch between tmux Terminal Sessions

To easily switch between different tmux sessions, you need to enable completion of sessions names. You can use the tmux completion extension to enable it as shown:

$ cd bin
$ git clone https://github.com/srsudar/tmux-completion.git

Then source the file ~/bin/tmux-completion/tmux in your ~/.bashrc file, by appending the following line in it.

source  ~/bin/tmux-completion/tmux

Save the file and close it.

Then close and reopen your terminal window, next time you enter the following command and press the Tab key, it should show you the possible session names.

$ tmux attach -t
Show tmux Terminal Sessions

Show tmux Terminal Sessions

Use Tmuxinator Session Manager

A session manager programmatically creates tmux workspaces by running a series of commands based on a config. The most widely used tmux session manager is tmuxinator.

Tmuxinator is a utility used to create and manage tmux sessions easily. To use it effectively, you should have a working knowledge of tmux. Importantly, you should understand what windows and panes are in tmux.

Use Zoom to focus on a Single Process

Last but not least, after opening up every panes, you want to focus on a single process, you can zoom the process to fill the entire screen. Simply move to the pane you want to focus on and press Ctrl+b, z (use the same to zoom out).

When you’re finished with the zoom feature, press the same key combo to unzoom the pane.


TOPICS: Computers/Internet
KEYWORDS: linux

1 posted on 02/26/2019 8:44:10 AM PST by ShadowAce
[ Post Reply | Private Reply | View Replies]

To: rdb3; Calvinist_Dark_Lord; JosephW; Only1choice____Freedom; Ernest_at_the_Beach; martin_fierro; ...

2 posted on 02/26/2019 8:44:32 AM PST by ShadowAce (Linux - The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

Know what? I would LOVE to see a screen shot of all these windows or split screens open at the same! I haven’t had the chance to play with any of these options yet. lol

Thanks for sharing this!


3 posted on 02/26/2019 8:58:48 AM PST by Openurmind
[ Post Reply | Private Reply | To 1 | View Replies]

To: Openurmind

I use Terminator as my terminal emulator. It allows tabs, groups, panes, etc. Pretty useful—especially the groups feature.


4 posted on 02/26/2019 9:01:38 AM PST by ShadowAce (Linux - The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 3 | View Replies]

To: ShadowAce

OK... Now I am only asking this because I have no idea so be patient with me. But is this for an environment where you have more than one user on a system? lol


5 posted on 02/26/2019 11:35:31 AM PST by Openurmind
[ Post Reply | Private Reply | To 4 | View Replies]

To: ShadowAce

How about logging for a tmux session?


6 posted on 02/26/2019 11:52:49 AM PST by chud
[ Post Reply | Private Reply | To 2 | View Replies]

To: chud

I just popped a bag of popcorn and waiting to hear more... lol


7 posted on 02/26/2019 1:08:11 PM PST by Openurmind
[ Post Reply | Private Reply | To 6 | View Replies]

To: Openurmind
No--it's just me. However, I tend to log into multiple servers at once, and I frequently will perform the same actions for each server.

With groups, my keystrokes are echoed to each window/server, and I can perform actions in parallel.

It really speeds things up.

8 posted on 02/26/2019 3:31:29 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 5 | View Replies]

To: chud
tmux logging
9 posted on 02/26/2019 3:32:34 PM PST by ShadowAce (Linux - The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 6 | View Replies]

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson