Use the boutique software application Tmux to maximize your terminal usage. It's free and can change your terminal productivity for ever! Demo included.
The terminal multiplexer, tmux, is a software application that helps manage multiple terminal connections.
Some of the major features
Tmux is a program that lives in your terminal and allows you to work on multiple things at once.
Client → Server → Session → Window → Panes
A client(you) connects to a server(local machine or remote). A tmux service is running in the background on that server and will do the magic of handling session/window management. The user then creates a new tmux session to do some work. Each tmux session contains a Window object (but there can be many) and within each Window, there are one (or many) panes.
Tmux requires a session. All output is captured in a session. All sessions are managed by the session manager.
A windows is attached to a tmux session and a window contains one or more panes. You can detach and reattach windows.
A new terminal window under a given tmux window.
The prefix key indicates you want to execute a tmux command. The default is control-b. You can change the prefix key, if you wish.
Listing all tmux windows: press control-b and then press ‘w’.
# Enter command-mode: ctrl-b # Enter text command-mode: ctrl-b : # Exit command-mode: esc # List command-mode shortcuts: ctrl-b ?
# osx brew install tmux
#debian sudo apt-get install tmux
There’s windows support. Apparently Windows 10+ comes with bash.
tmux attach || tmux
tmux new-session -s my-build
# enable ctl-b : setw synchronize-panes on # disable ctl-b : setw synchronize-panes off
For the demo we'll run three separate ubuntu docker containers, connect to each of them in a separate pane, and install java simultaneously on each container.
# download ubuntu docker image docker pull ubuntu # start 3 distinct containers from the ubuntu image docker run -h tmux-test-1 --name tmux-test-1 \ -d --rm -t ubuntu:latest docker run -h tmux-test-2 --name tmux-test-2 \ -d --rm -t ubuntu:latest docker run -h tmux-test-3 --name tmux-test-3 \ -d --rm -t ubuntu:latest
Now we'll create the tmux session, window, and 3 panes. One pane for each docker container we want to configure.
# see if there are any existing tmux sessions tmux ls # start a tmux session tmux new -s docker-configure-session # create a second pane ctl-b " # navigate between the panes ctl-b down-arrow ctl-b up-arrow # create a third pane ctl-b " # rearrange the panes vertically instead of horizontally ctl-b space # can do more ctl-b space to try different layouts # connect to each docker container. one in each pane. docker exec -it tmux-test-1 /bin/bash docker exec -it tmux-test-2 /bin/bash docker exec -it tmux-test-3 /bin/bash # tell tmux to issue keystrokes to all panes ctl-b : setw synchronize-panes on # make sure it works clear whoami uname -a # each pane should have a different hostname # update ubuntu package manager apt-get update clear # install java apt-get install openjdk-11-jdk y # test java -version