tmux is used to multiplex several virtual consoles to access multiple terminal sessions inside a single terminal window or remote terminal. tmux is like VNC, we can start application from one computer, without having to restart, we can reconnect, share the session, run multiple terminal sessions and so on. tmux can run on GNU Linux and all kind of UNIX or Unix Like OS. This guide is on on how to use tmux on Mac – more specifically – Apple’s computer running OS X 10.9 or higher.
How to Use tmux on Mac : The Basics
If you have followed this kind of guide to setup iTerm2, Homebrew and ZSH, you only need to run the command
brew install tmux. Homebrew is a package manager, ZSH is UNIX Shell; you should not get confused with Terminal Emulators and Terminal.
GNU Screen is a similar type of application, released in 1987. tmux is relatively newer, released in 2009. Whenever we talk about an environment, we usually point towards a dot file ending with
gvimrc – unfortunately, these are less spoken in technology blogs (those who claim to be Father of Technology Blog of X country…) but most important to learn. It is quite sad, if after using command line lightly for 2 years, one is unable to find .profile file. If these basics are not clear, decoration with syntax highlighting following a tutorial blindly can result in a condition for which www got attached to the naked domain names. In Linux, you possibly have used the
locate is disabled on Mac by default. If you run a command with
locate .zshrc, you’ll automatically get the instruction on how to enable
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
You can do these later,
find command can also find! Practically, on command line, you will get an interface like FileZilla, if you can not use the basic powerful commands, we guess; the experience will not be great. Many two worded commands can make an UNIX system unusable. If you run (be careful) the command
vim ~/.vimrc, you’ll face a warning type of interface. The default file which is in use, must not be overwritten. Vundle is plugin manager for Vim :
.vimrc is again arriving. We want to tell you, you should keep everything rightly ordered before using tmux. A simple command can make login to OS X difficult. Update your Xcode and Xcode Command Line Utilities. This ends the basics.
How to Use tmux on Mac : Get Started
Now, you have everything right. Running the command
tmux, starts tmux. If you are getting
[EXITED], you should check and update your setup. tmux will have own configuration file. These are usual shortcuts for tmux :
Ctrl+b ” = horizontally split
Ctrl+b % = vertically split
Ctrl+b arrow key = switch pane
Ctrl+b c = create a new window
Ctrl+b n = Next
Ctrl+b p = Previous
Ctrl-b o = Switch
Ctrl-b ? = All commands
There is separate configuration file named
.tmux.conf. This the practical primer, rest is written on the official website
Why Vim, Vi, Nano?
The usage of nano and vim are different. Vim is never user friendly. The original Vim was more difficult! But Vim is very powerful. For editing
nginx.conf, Vim; honestly not required. Nano is better to add a right block of snippet. You need not to do a huge work to find the last “}” closure! In tmux usage, you need to know about Vim. Vi and Father of Nano (i.e. Pico) all are near about 40 years old text editors! Functionally, vim is almost a proper superset of vi. So, everything that is in vi is available in vim (Vi Improved). I heard original Vi was very difficult, those version are older than me!
On OS X you can see in graphical user interface, on SSH, if you need to work on core files, vi is helpful for greater support for regular expression.