tools

Making A Beautiful Terminal

Custom terminal with iterm2, powerlevel10k, vim, dracula, and more
Custom terminal with iterm2, powerlevel10k, powerline fonts, nerd fonts, neofetch and vim theme dracula, and more

I spent time setting up a new MacOS terminal recently. Not only does the terminal look great but it visually keeps my place with Git, shows current Kubernetes cluster, glcoud project, AWS project, virtual environments and more by default. There are tons of other metrics enabled and lots more hacks you can add to your prompt.

The prompt lets you know when you added code, commited code to your local repo, and pushed.

When you start writing out kubectl, helm, kubens, kubectx, oc, istioctl, kogito, k9s, helmfile, fluxctl or stern the prompt automatically shows you what Kubernetes cluster you have currently set. Just like any other information that appears automatically, you can set this to be always on.

To read about all the prompt features skip to the section labeled ‘Powerlevel10k’

How I did it all

I am not going to tell you how to install everything here because I’ve seen alot of outdated stuff while installing my setup from many of the other blogs out there.

Instead I will show you the links you need in the exact order for installing everything . This way if any of the docs update you are still in the clear and don’t run into pit falls.

ITerm2

To start off, I switched out the stock Mac OS Terminal.app for ITerm2 for the 24-Bit colors, image display, and hotkeys alone, but many more features are at play.

The colors are unmatched in this terminal compared to stock.

Read about the latest list of features or how to install at the link below

https://iterm2.com

Next install a color presets package for your term profiles. This adds profiles ( themes ) for your choosing inside of ITerm2

I picked ‘Dark Pastel’ to give you the colors you see in my terminal. Follow the link below to install.

https://iterm2colorschemes.com/

Keep in mind you will still want a VIM theme and you will still want to configure your prompt. iTerm2 profiles set the color palette, which defines the rgb of named colors.

Vim, prompt and other themes don’t define rgb so much as it chooses which of the iTerm2 named colors to use for each item.

If your VIM theme ends up looking off compared to what is shown online try playing with your iTerm2 profile

I did notice that using my old hotkeys for skipping words was not working correctly, so I recreated it and posted a video about how to do it.

How to enable skipping words in iTerm2 on Mac OS

I quick overview of how to enable skipping words in the Mac OS version of iTerm2

Zsh

A Shell that is almost identical to Bash. It might already be installed on newer Mac OSes, but is easily installed with homebrew if not.

Why Zsh?

  • Automatic cd: By just typing the directory name
  • Recursive path expansion: As an example “/e/ls/c” expands to “/etc/squid/config”
  • Spelling correction and approximate completion: Make a small mistake typing a directory name? ZSH will fix it
  • Plugin and theme support: ZSH contains many different plugin frameworks and is very extensible.

https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH

Oh My Zsh

Framework for managing your zsh configuration. Includes 300+ optional plugins (git, OSX, docker, homebrew, node, python, and many more) and 140+ themes

https://ohmyz.sh/

Neofetch

The ASCII Mac OS apple in my terminal with the stats next to it is called Neofetch.

This can be customized with pretty much what ever you want for icons and stats.

Installation is simple with brew on Mac and then add your command with options to your .zshrc to customize and run.

Find Neofetch info at the following link

https://github.com/dylanaraps/neofetch

My current neofetch which is running completely stock in this photo. You can even add graphs!

Powerline and Nerd Fonts

This gives you the icons you need to get all the flashy symbols you see in my Powerlevel10k prompts below.

If you see that your prompt doesn’t look like others online check your fonts again because you might be missing some.

Powerline fonts: https://github.com/powerline/fonts

Nerd Fonts: https://github.com/ryanoasis/nerd-fonts

Powerlevel10k

My prompt is stripped down , but many metrics can be added.

Some metrics appear and disappear when needed. Here you can see my Kubernetes cluster name popup when typing ‘kubectl’. This can be configured to remain on to constantly.

Here is an example of working within a Git repo

There is an unlimited number of things that the prompt does and it can be configured using a easy ‘p10k configure’ command.

My current prompt colors and style is called the ‘Rainbow prompt’, but there are many others to choose from.

I have enabled the battery indicator in my prompt but you can add anything you see in the config text below.

This configuration below is directly from the powerlevel10k config file. Just remove the # from the beginning of a line to enable a extra indicator

I have found that most any customization ideas I had to play with were covered in the documentation.

The docs are next level and i would recommend this prompt on that alone.

status                  # exit code of the last command
    command_execution_time  # duration of the last command
    background_jobs         # presence of background jobs
    direnv                  # direnv status (https://direnv.net/)
    asdf                    # asdf version manager (https://github.com/asdf-vm/asdf)
    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
    anaconda                # conda environment (https://conda.io/)
    pyenv                   # python environment (https://github.com/pyenv/pyenv)
    goenv                   # go environment (https://github.com/syndbg/goenv)
    nodenv                  # node.js version from nodenv (https://github.com/nodenv/nodenv)
    nvm                     # node.js version from nvm (https://github.com/nvm-sh/nvm)
    nodeenv                 # node.js environment (https://github.com/ekalinin/nodeenv)
    # node_version          # node.js version
    # go_version            # go version (https://golang.org)
    # rust_version          # rustc version (https://www.rust-lang.org)
    # dotnet_version        # .NET version (https://dotnet.microsoft.com)
    # php_version           # php version (https://www.php.net/)
    # laravel_version       # laravel php framework version (https://laravel.com/)
    # java_version          # java version (https://www.java.com/)
    # package               # name@version from package.json (https://docs.npmjs.com/files/package.json)
    rbenv                   # ruby version from rbenv (https://github.com/rbenv/rbenv)
    rvm                     # ruby version from rvm (https://rvm.io)
    fvm                     # flutter version management (https://github.com/leoafarias/fvm)
    luaenv                  # lua version from luaenv (https://github.com/cehoffman/luaenv)
    jenv                    # java version from jenv (https://github.com/jenv/jenv)
    plenv                   # perl version from plenv (https://github.com/tokuhirom/plenv)
    phpenv                  # php version from phpenv (https://github.com/phpenv/phpenv)
    scalaenv                # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
    haskell_stack           # haskell version from stack (https://haskellstack.org/)
    kubecontext             # current kubernetes context (https://kubernetes.io/)
    terraform               # terraform workspace (https://www.terraform.io)
    aws                     # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
    aws_eb_env              # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/)
    azure                   # azure account name (https://docs.microsoft.com/en-us/cli/azure)
    gcloud                  # google cloud cli account and project (https://cloud.google.com/)
    google_app_cred         # google application credentials (https://cloud.google.com/docs/authentication/production)
    context                 # user@hostname
    nordvpn                 # nordvpn connection status, linux only (https://nordvpn.com/)
    ranger                  # ranger shell (https://github.com/ranger/ranger)
    nnn                     # nnn shell (https://github.com/jarun/nnn)
    xplr                    # xplr shell (https://github.com/sayanarijit/xplr)
    vim_shell               # vim shell indicator (:sh)
    midnight_commander      # midnight commander shell (https://midnight-commander.org/)
    nix_shell               # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html)
    vi_mode                 # vi mode (you don't need this if you've enabled prompt_char)
    # vpn_ip                # virtual private network indicator
    # load                  # CPU load
    # disk_usage            # disk usage
    # ram                   # free RAM
    # swap                  # used swap
    todo                    # todo items (https://github.com/todotxt/todo.txt-cli)
    timewarrior             # timewarrior tracking status (https://timewarrior.net/)
    taskwarrior             # taskwarrior task count (https://taskwarrior.org/)
    time                    # current time
    # ip                    # ip address and bandwidth usage for a specified network interface
    # public_ip             # public IP address
    # proxy                 # system-wide http/https/ftp proxy
    # battery               # internal battery
    # wifi                  # wifi speed
    # example               # example user-defined segment (see prompt_example function below)

Find the Powerlevel10k repo below.

https://github.com/romkatv/powerlevel10k

Tmux

The multiple terminals that you are seeing is called Tmux. This can split your terminal with each ‘window’ of ‘panes’ being a new ‘session’.

Tmux is great for terminals on servers because as long as your server stays up your window will remain open even if you get disconnected. Say you lose your network or timeout. All you have to do is just reattach to your session after your network returns.

I have even pressed hotkeys that killed my local term yet my work was saved because the session was still live.

An example of tmux can be seen here.

Example of multiple terminals open in Tmux

https://github.com/tmux/tmux/wiki

VIM

I think I will leave my entire VIM configuration for another post, but I will still go over the theme that you can see here.

The VIM theme is called Dracula. This is what is looks like in an iTerm2 with the ‘Dark Pastel’ profile

There are sites that show you the most upvoted VIM themes. Try and find you one of these themes as the most upvoted themes are typically the ones that look the best.

VIM theme ‘Dark Pastel’

Dark Pastel can be found in the following repo. I found many more repos listed at the bottom of the README doc.

https://github.com/rafi/awesome-vim-colorschemes

PROTIP: Use Vundle or another package manager to simply your VIM or NeoVIM plugin installs. Trust me on this. You don’t want to manually install stuff on VIM. I have been there and done that.

https://github.com/VundleVim/Vundle.vim

Happy hacking !

Leave a Reply