10/13/2019»»Sunday

Tmux For Mac

10/13/2019
    38 - Comments
Tmux For Mac Rating: 3,5/5 5167 reviews

Its been quite long I am using Tmux. Terminal muxer, or multiplexer. Tmux is beautiful utility to make your terminal more powerful. Once you install Tmux your terminal can be divided into multiple sessions and can increase parallelism.

  • A sessions can have multiple windows.
  • A window is a single view.
  • A Window can further split into panes.

Let's up our game and get Tmux into the mix. We can use Tmux to open up multiple 'panes' within our shell. First, install it. On your Mac, you can use Homebrew: $ brew install tmux. Ubuntu or Debian users can user apt-get: $ sudo apt-get install tmux. Now, colors are also an issue when running Vim within Tmux. Let's fix that. Now, after all configuration, the biggest pain is you have to open the terminal, change to tmux and then start zsh and then do work. But what we want is iTerm default opens in Zsh. Now, I prefer that it doesn't open with tmux by default, because there are scenarios where I want to work outside of tmux sessions, so I leave tmux to be started by me. Install and configure tmux on Mac OS X. GitHub Gist: instantly share code, notes, and snippets. Tmux is an application that I use in my terminal to manage several programs running at once. I've used it on Linux and Mac, it's one of the first things I install on a new computer along with Zsh and asdf. The tmux wiki refers to tmux as a 'terminal multiplexer;' basically, it lets you run several programs in one terminal window (and do some other really cool stuff). Tmux supports Alt+key (Meta+key) by prefixing the key with M-, or Ctrl+key with the C-prefix in the key binding specification. There is no support for any other modifier keys. There is no support for any other modifier keys. Nov 12, 2014  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.

Tmux installation is straight forward. It is available as package in almost all major linux distributions.

Tmux can be installed on all major Linux/mac with below commands.

prefix + d is be default but I do use prefix + t , that means you would first hit (and release) Control + b and then type d.

Session

Tmux For Mac Torrent

For your first session simply type tmux in terminal:

This will create a new tmux session. Once you run above command you will see your terminal turns like below.

Just use exit to get out of your tmux first session. Just remember ctrl + b is your default prefix.

Note:- (= prefix ctrl +b)

Pane(s)

Terminal can be split further into numerous panes. prefix + % for vertical split and prefix + “ for horizontal split.

To navigate between pane use prefix + arrow-keys .
To close panes ctrl+d or simply exit.
To make pane full size just hit prefix + z.
To toggle between different pane prefix + o.
Also to display clock in pane hit prefix + t.

Some useful commands

  1. List all the running sessions

You should see below like output for above command

0: 1 windows (created Fri Aug 31 15:10:27 2018) [173x45] (attached)

2. Start new session in tmux with name

Please change abhishekamralkar to whatever you want to name your session.

3. To attach to sessions

Best printers for apple macbook. Above command with attach us to session 0.

To check what all commands available with tmux run

A week or so ago a colleague turned me on to oh-my-zsh and I just went down the rabbit hole. I have always found the built-in Terminal in macOS (formerly OS X) to be bland and boring, but never really sat down to try to change it. I started using iTerm2 awhile ago, but again, never tried to 'spice it up' so to speak. Now I did and I came up with this:

First off, make sure you're using iTerm2, if you're not already.

Next, we will have to install oh-my-zsh and tmux before setting up Powerlevel9k and your vim settings. There are a few caveats to getting everything setup neatly on Mac, so this post will go over that.

I used Homebrew to install tmux by simply typing the following:

If you don't have brew installed, you can do so by typing:

You can follow the documentation on GitHub, or simply use the following command:

Tmux For Mac

After the install completes, you will want to enable some plugins and set a theme in your .zshrc file.

The plugins I have enabled are as follows:

Note: I had to manually install the following:

- zsh-completions
- zsh-autosuggestions
- zsh-syntax-highlighting

Next, the theme I used is Powerlevel9k, which I will get to next. To set it in my .zshrc file I used:

Luckily, the install for Powerlevel9k is super simple for oh-my-zsh. Simply run the following command:

In most cases, you will need a powerline font. Powerline was a bitch to try to install on macOS with the new python packages, so I used tools that were inspired by it. The font I used is here; alternatively, you can install all powerline fonts by running:

You will need to set whichever font you want in your iTerm2 preferences. Note the font selected in my preferences:

Now that you have oh-my-zsh, tmux, and powerlevel9k installed, let's get to configuring everything.

Tmux Mac Scroll

Configuration

First, I selected the 'Darkside' color preset for iTerm2 because it reminded me of Star Wars. You can get a bunch of presets for iTerm2 here.

My terminal was inspired by a bunch of different user's screenshots, but two that stand out are Semartin's and Sevenfoxes', specifically because of the Spotify, wifi, and battery info. Rather than having the info show in my terminal, I opted to include it as part of my tmux configuration. In order to have tmux launch every time I opened iTerm2 (and thus, zsh), I needed to add the following to my .zshrc file:

Mac stands for makeup. RankAbbreviationMeaning.Make-Up Art Cosmetics, Inc.Maximum Asset Capability.Maximum Allowable Charge.Managed Account.Money Access Center.Mobile Air Conditioner.Moore Action Collectibles.Mid America Corvette.Milestone Achievement Certificate.Mooney Airplane Company.Michigan Aerospace Corporation.Morgan Advanced Ceramics.Ma’aden Aluminum Company.Manufacturing Assistance Center.Marubeni America Corporation.Media Air Cleaner.Midwest Airlines Center.Macerich Company (New York Stock Exchange NYSE).

My full zshrc file can be found here.

I ultimately took what I needed from their .tmux.conf configs and threw them into .sh scripts, which can be accessed here. My status line config for my .tmux.conf is as follows:

My full tmux.conf can be found here. Note: To get the now_playing.sh with Spotify to work, you will have to install shpotify:

I also installed the tmux-current-pane-hostname plugin (bottom right corner) so it will auto populate with the hostname when I am connected to an ssh session, or disply my hostname when disconnected.

Vim

Last, but not least, Vim! I had a hell of a time configuring Vim at first because I was trying to set it up using Powerline. I used this post as a guide, but was unable to configure things the way I wanted. Regardless, I am including the link in case it's helpful to you. I ended up choosing vim-airline because it's lightweight and simple.

To start, I configured my .vimrc file to use Vundle.

Then, put this at the top of your .vimrc file:

Next, to install plugins type 'vim +PluginInstall +qall' from command line or launch vim and run ':PluginInstall'

After you have Vundle setup, you can add these two plugins to your .vimrc and run your preferred command to install the plugins again:

This will install vim-airline and vim-airline-themes.

Now, to always show the statusline in Vim, you have to add:

I went with the wombat colorscheme for now. Also, I found a bunch of vimthemes here. For my vim-airline plugin, I went with the bubblegum theme.

Next, I wanted to install Nerdtree, but first I decided to install Pathogen to keep present and future installs simple:

I added the following to my .vimrc to enable pathogen:

Tmux mac tutorial

Now I could install Nerdtree:

I added the following minor customizations, again, to my .vimrc to tell Nerdtree to startup with Vim every time, map the NerdTreeToggle to 'Ctrl+n', and have the cursor stay in the edit area by default on launch.

My complete .vimrc file can be accessed here.

Finally, my iTerm2 configuration, as well as every dotfile and .sh mentioned here, can be downloaded here.