12-09-2015, 02:54 PM
I love working with the command line. Seriously, I think there’s hardly any more productive and more versatile tool for a software developer than the terminal. Maybe it’s the hacker/wizard/neckbeard kind of feeling I get when using a terminal, I don’t know.
At work we do lots of pair programming. Everyone’s got their own laptop and can set it up the way they like. And since I love working with the command line I’ve spent quite some time doing (only sane! I swear!) modifications to my terminal environment that make working with the command line more pleasant and streamlined. This is why my pair usually will be greeted by something like this:
What's tmux?
tmux’s authors describe it as a terminal multiplexer. Behind this fancy term hides a simple concept: Within one terminal window you can open multiple windows and split-views (called “panes” in tmux lingo). Each pane will contain its own, independently running terminal instance. This allows you to have multiple terminal commands and applications running visually next to each other without the need to open multiple terminal emulator windows.
On top of that tmux keeps these windows and panes in a session. You can exit a session at any point. This is called “detaching”. tmux will keep this session alive until you kill the tmux server (e.g. when you reboot)2. This is incredibly useful because at any later point in time you can pick that session up exactly from where you left it by simply “attaching” to that session.
If you’ve ever worked with remote servers or a Raspberry Pi over ssh you can guess where this will be useful: When you lose your ssh connection the tmux session will simply be detached but will keep running on the server in the background including all the processes that run within your session. To continue your session simply ssh to the server again and attach to the running session.
But tmux is not only helpful when working on a remote machine. Not only for its window management features but also for the session handling. Personally I find myself detaching from sessions when I’m switching context. I’ll just start a new session for my new task and attach to the old session whenever I want to continue with my old task.
You see that tmux basically offers two big features: Window management in your terminal and session management. If you are familiar with GNU Screen this is nothing new. Think of tmux as an easier-to-use and a little more powerful alternative to Screen (obviously I’m being opinionated here).
Enough with the talking already. Let’s get our hands ready in the hands-on guide!
Installation:
We are going to install tmux on our machine, i'm running on Debian based distro:
Tmux Config: Tmux Config Link ( save as to /home/USERNAME/.tmux.conf or /root/.tmux.conf )
Keybindings:
Prefix (you probably won't need it)
The following key bindings do not require you to send the prefix keystroke:
Split vertically
Split horizontally
Go to the left pane
Go to the bottom pane
Go to the top pane
Go to the right pane
Equal vertial panes
Equal horizontal panes
Resize pane
Copy mode and page up
Copy mode
Paste
Choose a session to attach
Cycle left through sessions
Cycle right through sessions
Note: sorry for my bad english!
At work we do lots of pair programming. Everyone’s got their own laptop and can set it up the way they like. And since I love working with the command line I’ve spent quite some time doing (only sane! I swear!) modifications to my terminal environment that make working with the command line more pleasant and streamlined. This is why my pair usually will be greeted by something like this:
Spoiler! :
What's tmux?
tmux’s authors describe it as a terminal multiplexer. Behind this fancy term hides a simple concept: Within one terminal window you can open multiple windows and split-views (called “panes” in tmux lingo). Each pane will contain its own, independently running terminal instance. This allows you to have multiple terminal commands and applications running visually next to each other without the need to open multiple terminal emulator windows.
On top of that tmux keeps these windows and panes in a session. You can exit a session at any point. This is called “detaching”. tmux will keep this session alive until you kill the tmux server (e.g. when you reboot)2. This is incredibly useful because at any later point in time you can pick that session up exactly from where you left it by simply “attaching” to that session.
If you’ve ever worked with remote servers or a Raspberry Pi over ssh you can guess where this will be useful: When you lose your ssh connection the tmux session will simply be detached but will keep running on the server in the background including all the processes that run within your session. To continue your session simply ssh to the server again and attach to the running session.
But tmux is not only helpful when working on a remote machine. Not only for its window management features but also for the session handling. Personally I find myself detaching from sessions when I’m switching context. I’ll just start a new session for my new task and attach to the old session whenever I want to continue with my old task.
You see that tmux basically offers two big features: Window management in your terminal and session management. If you are familiar with GNU Screen this is nothing new. Think of tmux as an easier-to-use and a little more powerful alternative to Screen (obviously I’m being opinionated here).
Enough with the talking already. Let’s get our hands ready in the hands-on guide!
Installation:
We are going to install tmux on our machine, i'm running on Debian based distro:
Quote:sudo apt-get install tmux
Tmux Config: Tmux Config Link ( save as to /home/USERNAME/.tmux.conf or /root/.tmux.conf )
Keybindings:
Code:
Alt + E
Prefix (you probably won't need it)
The following key bindings do not require you to send the prefix keystroke:
Code:
Alt + |
Split vertically
Code:
Alt + -
Split horizontally
Code:
Alt + H
Go to the left pane
Code:
Alt + J
Go to the bottom pane
Code:
Alt + K
Go to the top pane
Code:
Alt + L
Go to the right pane
Code:
Alt + =
Equal vertial panes
Code:
Alt + +
Equal horizontal panes
Code:
Alt + Arrow
Resize pane
Code:
Alt + PageUp
Copy mode and page up
Code:
Alt + U
Copy mode
Code:
Alt + I
Paste
Code:
Alt + 8
Choose a session to attach
Code:
Alt + 9
Cycle left through sessions
Code:
Alt + 0
Cycle right through sessions
Note: sorry for my bad english!
I'm a bit of a hacker fanatic and know a fair bit about that industry and cyber crime and cyber warfare.