Installing Oh-My-Zsh on Ubuntu 20.04
In order for Oh-My-Zsh to work on the system ,zsh
need to be installed.
Install ZSH
apt install wget curl git -y
apt install zsh
To check installed version of ZSH:
zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)
Changing your default shell to zsh:
usermod -s $(which zsh) root
chsh -s $(which zsh)
Install Oh-my-Zsh
Clone the repo:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
or
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
The Oh-my-Zsh configuration files are located under $HOME/.oh-my-zsh/
directory. Note that ZSH config file is $HOME/.zshrc
.
Theming
nano $HOME/.zshrc
robbyrussel
is the default theme for ZSH:
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
...
To change the theme, simply get the name of the theme from $HOME/.oh-my-zsh/themes/
and replace it. For example, to change the themes to bureau theme, $HOME/.oh-my-zsh/themes/bureau.zsh-theme
:
ZSH_THEME="bureau"
Reload the ~/.zshrc
to effect the changes everytime you make changes.
source ~/.zshrc
Enable Oh-My-Zsh Plugins
Plugins are stored under ~/.oh-my-zsh/plugins
. Plugins can be enabled by defining them under the plugins section on ~/.zshrc
config file:
plugins=(git docker-compose docker ansible vagrant sudo)
Save and exit the shell. Then source ~/.zshrc for the changes to take effect.
source ~/.zshrc
External Plugins
Clone the desired plugin - e.g. zsh-autocomplete and add it to your .zshrc
file:
cd /home/ubuntu
git clone https://github.com/marlonrichert/zsh-autocomplete.git
nano .zshrc
Add the following to your .zshrc file:
source /home/ubuntu/zsh-autocomplete/zsh-autocomplete.zsh
Adding EXA
exa is a modern replacement for the venerable file-listing command-line program ls that ships with Unix and Linux operating systems, giving it more features and better defaults. It uses colours to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git. And it’s small, fast, and just one single binary.
apt install exa
Adding a shortcut in nano .bashrc
:
alias dir='exa -abghHlS --tree'
Command-line options
exa’s options are almost, but not quite, entirely unlike ls’s.
Display options
-1, --oneline | display one entry per line |
-G, --grid | display entries as a grid (default) |
-l, --long | display extended details and attributes |
-R, --recurse | recurse into directories |
-T, --tree | recurse into directories as a tree |
-x, --across | sort the grid across, rather than downwards |
-F, --classify | display type indicator by file names |
--colo[u]r | when to use terminal colours |
--colo[u]r-scale | highlight levels of file sizes distinctly |
--icons | display icons |
Filtering options
-a, --all | show hidden and 'dot' files |
-d, --list-dirs | list directories like regular files |
-L, --level=(depth) | limit the depth of recursion |
-r, --reverse | reverse the sort order |
-s, --sort=(field) | which field to sort by |
--group-directories-first | list directories before other files |
-D, --only-dirs | list only directories |
--git-ignore | ignore files mentioned in .gitignore |
-I, --ignore-glob=(globs) | glob patterns (pipe-separated) of files to ignore |
Pass the --all option twice to also show the . and .. directories.
Long view options
These options are available when running with --long (-l)
-b, --binary | list file sizes with binary prefixes |
-B, --bytes | list file sizes in bytes, without any prefixes |
-g, --group | list each file’s group |
-h, --header | add a header row to each column |
-H, --links | list each file’s number of hard links |
-i, --inode | list each file’s inode number |
-m, --modified | use the modified timestamp field |
-S, --blocks | list each file’s number of file system blocks |
-t, --time=(field) | which timestamp field to use |
-u, --accessed | use the accessed timestamp field |
-U, --created | use the created timestamp field |
-@, --extended | list each file’s extended attributes and sizes |
--changed | use the changed timestamp field |
--git | list each file’s Git status, if tracked or ignored |
--time-style | how to format timestamps |
--no-permissions | suppress the permissions field |
--no-filesize | suppress the filesize field |
--no-user | suppress the user field |
--no-time | suppress the time field |
Some of the options accept parameters
- Valid --color options are always, automatic, and never.
- Valid sort fields are accessed, changed, created, extension, Extension, inode, modified, name, Name, size, type, and none. Fields starting with a capital letter sort uppercase before lowercase. The modified field has the aliases date, time, and newest, while its reverse has the aliases age and oldest.
- Valid time fields are modified, changed, accessed, and created.
- Valid time styles are default, iso, long-iso, and full-iso.
Manual Update Oh-My-ZSH
rm -rf ~/.oh-my-zsh && git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh