Working on Linux systems means that one is using the command line more often than not. Having to type long directory names over and over as well as guessing command names eats up valuable time. This can add up very quickly. Z is a tool that records every directory you browse and compiles a weighted list of the most frequent/recently used ones. Zsh is an alternative to bash (the default shell that come with most Linux distros) that adds subtle improvements like spelling correction of words/commands and better tab-completion.
Spin-up a Vultr instance running CentOS (either version 6 or 7) and follow the steps below to add a new admin (sudo) user. We're doing this because it is along the lines of best practices to create a new user and assign it admin rights to access the server, rather than use the root user.
usermod -a -G wheel <newuser>.
echo ' <newuser> ALL=(ALL) ALL' >> /etc/sudoers.
You should be in your home directory after you logon as "newuser" (otherwise, run
cd ~). Follow the next set of steps to install Z. Note that since Z is a script, what we do is download it to our home directory and tell our default shell to run Z anytime it starts.
printf "\n\n#initialize Z (https://github.com/rupa/z) \n. ~/z.sh \n\n" >> .bashrc. This command appends
. ~/z.shto your
.bashrcfile, which in turn tells it to run Z upon start-up.
To test how Z works, browse to these directories:
cd /etc/cloud/templates cd /usr/share/nano cd /etc/pki/java cd ~
Now, from your terminal, type in
z clo and push the tab button, then enter. Next, type
z nano and hit the tab button, then enter again. You will see in both cases that Z automatically knew to
cd into the first and second directories where we initially browsed.
sudo yum update && sudo yum -y install zsh.
chsh -s /bin/zsh. You will be prompted to enter your password.
If you are greeted with a Zsh shell configuration prompt, select "2", then "1", then "0" to accept the default settings.
To test things out, type "
kill " and push the tab button (there is a space after
kill). Zsh will automatically show you a list or processes to kill as oppose to doing nothing.
Zsh also shares your terminal history across multiple windows/sessions, and has tons of other useful features. There are also frameworks built on top of Zsh that even add more dazzling features to it, such as oh-my-zsh and prezto.
printf "\n\n#initialize Z (https://github.com/rupa/z) \n. ~/z.sh \n\n" >> .zshrc. This command appends
.zshrcfile, which tells it to run Z on start-up.
Note: If you do not like the default settings, you can update the Zsh shell configuration by editing the
.zshrc file (in your home directory), or by running the following commands:
autoload -U zsh-newuser-install zsh-newuser-install -f source ~/.zshrc
Z and Zsh are useful tools that may drastically help increase your productivity.
Written by Lami Adabonyan