Ubuntu ZSH + Powerlevel10K + Plugins
The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
To install it, together with the PowerLine Glyphs icons, run:
sudo apt install -y zsh fonts-powerline- Assuming that a Nerd Font is already installed and configured: https://www.nerdfonts.com/font-downloads
🙃 A delightful community-driven (with 2,000+ contributors) framework for managing zsh configuration It includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
To install it, run:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"For the main theme, we will use PowerLevel10K from https://github.com/romkatv/powerlevel10k. Powerlevel10k is a theme for ZSH. It emphasizes speed, flexibility and out-of-the-box experience. Installation is very quick by running:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10kWe need to edit the ZSH config file to state that we want to use Oh-My-ZSH by replacing the values of ZSH_THEME="robbyrussell":
nano ~/.zshrcZSH_THEME="powerlevel10k/powerlevel10k"We will need then to configure ZSH to use this theme by running:
p10k configure- Go through the wizard and choose your preferred options
In order to suppress the warning and make our login process quicker, we will add this to the configuration file, which is located in ~/.p10k.zsh, and change the value verbose for quiet:
nano ~/.p10k.zshtypeset -g POWERLEVEL9K_INSTANT_PROMPT=quietOh-My-Zsh comes bundled with plugins, which allow to take advantage of functionality of many sorts to the shell just by enabling them. Enable a plugin by adding its name to the plugins array in the .zshrc file (found in the $HOME directory). For example, this enables the rails, git and ruby plugins, in that order:
plugins=(rails git ruby)Some of them need to be installed with curl for the plugin into the respective config file with one command. Our preferred ones from this list: https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
- ZSH Auto-Suggestions: As you type, you’ll see a suggested completion come up in a faded gray color
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions- sudo: this plugin takes what you just typed and adds a
sudoat the beginning for you. The shortcut is to hit the escape key twice. - copyfile: copy the contents of a file to the clipboard
- jsontools: this plugin has a number of neat capabilities, but I mainly use it to pretty print json. Just pipe your call with
| pp_json - git: this plugin provides many aliases and a few useful functions
- aws: this plugin provides completion support for awscli and a few utilities to manage AWS profiles and display them in the prompt
- helm: this plugin adds completion for Helm, the Kubernetes package manager
- kubectl: this plugin adds completion for the Kubernetes cluster manager, as well as some aliases for common kubectl commands
- kubectx: this plugins adds kubectx_prompt_info() function. It shows name of the active kubectl context (kubectl config current-context)
- nmap: this plugin adds some useful aliases for Nmap similar to the profiles in zenmap
- ubuntu: this plugin adds completions and aliases for Ubuntu
So, in our case, we would add these ones:
nano ~/.zshrcplugins=(git zsh-autosuggestions sudo copyfile jsontools aws helm kubectl kubectx nmap ubuntu)Neofetch is a command-line system information tool written in bash 3.2+. Neofetch displays information about your operating system, software and hardware in an aesthetic and visually pleasing way.
The information by default is displayed alongside your operating system's logo. You can further configure Neofetch to instead use an image, a custom ASCII file, your wallpaper or nothing at all.
To install it, run:
sudo apt install -y neofetchWe can edit the values in the config file, per example, adding local and public IP and disk usage:
nano ${HOME}/.config/neofetch/config.confWe could also add the current weather temperature by adding this line to the config file:
prin "Weather" "$(curl wttr.in/?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"For it all to work, we need to edit the ~/.zshrc to add the binary neofetch.
We can set ZSH or BASH are our default by using these commands:
chsh -s $(which zsh)
chsh -s $(which bash)