A beautiful Terminal

This article is a bit old now, and I wrote a more recent article on the matter, check it out there: https://ntag.fr/my-dev-macos-setup/.


Hello! It has been a while without any article, I have been very busy. But now, I hope I will have more time (and I will try to write in English).

The terminal has existed for a long time, and is still very used by developers; but the terminal of today is far away from the terminal of 1990. Today you have colors, high resolution, UTF-8... It would be very sad not to use all these new capabilities!

Result

Here is how my terminal looks:
Beautiful Terminal

There are:

  • tmux, zsh
  • command syntax coloration
  • command auto-complete
  • colors
  • git information
  • last command status code (if error)
  • hostname
  • username
  • date
  • system load
  • system uptime

How to get that?

Prepare your terminal

  1. Use a real terminal, like iTerm2 on Mac OS X. See this list on Linux.
  2. Install and use a Powerline-patched font: https://github.com/powerline/fonts. I use Meslo. Just clone the repository, go in Meslo folder and install Meslo LG S Regular for Powerline.otf. Then, tell your terminal to use it.

Configure your system

(Tested on Ubuntu 14.04, Ubuntu 15.10, Debian 8.3)

  1. Install ZSH

    • sudo apt-get install git zsh
  2. Install OhMyZSH

    • sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  3. Install zsh-autosuggestions

    • git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
    • Edit ~/.zshrc and replace line plugins=(git) with plugins=(git zsh-autosuggestions)
    • Create a file ~/.oh-my-zsh/custom/colors.zsh containing ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=240'
  4. Install zsh-syntax-highlighting

    • git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    • Edit ~/.zshrc and replace line plugins=(git zsh-autosuggestions) with plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
    • Note: if you have issues with this plugin, go in ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting and execute git checkout 0.4.1
  5. Install Powerline

    • Install pip: (in root) curl https://bootstrap.pypa.io/get-pip.py | python
    • sudo pip install powerline-status
    • Find where Powerline has been installed: pip show powerline-status and look the line Location: (for me it's /usr/local/lib/python2.7/dist-packages). We will call it {repository_root}
    • In ~/.zshrc add the following line at the end: . {repository_root}/powerline/bindings/zsh/powerline.zsh (replace {repository_root} with the previous value; for me it gives: . /usr/local/lib/python2.7/dist-packages/powerline/bindings/zsh/powerline.zsh)
  6. Install tmux >= 1.9

    • You can check the version installed with tmux -V
    • On Ubuntu 14.04
    • sudo apt-get install -y python-software-properties software-properties-common tmux
    • sudo add-apt-repository -y ppa:pi-rho/dev
    • sudo apt-get update
    • sudo apt-get install tmux
  7. Add Powerline to tmux

    • Create a file ~/.tmux.conf and put inside:

        set -g default-terminal "screen-256color"
        run-shell "powerline-daemon -q"
        source "/usr/local/lib/python2.7/dist-packages/powerline/bindings/tmux/powerline.conf"
        ## Start windows and panes at 1, not 0
        set -g base-index 1
        setw -g pane-base-index 1
      
        # pane border
        set-option -g pane-border-fg colour235 #base02
        set-option -g pane-active-border-fg colour240 #base01
      
        # message text
        set-option -g message-bg colour235 #base02
        set-option -g message-fg colour166 #orange
      
        # pane number display
        set-option -g display-panes-active-colour colour33 #blue
        set-option -g display-panes-colour colour166 #orange
      

It should work the same on Mac OS X, just replace apt-get with brew (and if you haven't Homebrew (whaaaat?) go right now here).

Happy configuration, enjoy your terminal!