zsh and antigen - installation to customization
A guide to install and customize zsh along with different plugins with the help of antigen plugin manager. But what are those?
ZSH and Antigen
ZSH
The Z shell! A Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting.
Antigen
Yet, an another plugin manager for zsh!
Antigen’s official docs says,
Why zsh?
Why? We’ve bash, right? Well, you can extend it’s features more easily along with awesome customizations! Do you need anything else?
Z shell’s official website says,
Still confused? Well, just try once, if you don’t like it you can always revert back 😆.
Why antigen?
We’ve got a lot of popular zsh plug-in managers like oh-my-zsh, zplug and so on. So why antigen?
- It’s fast ✨
And I think it’s more easier. 🎯
Installing zsh
You can most probably install right from your operating system’s official package manager. Alternatively, you can check this list, if you need help installing zsh.
To make sure zsh is installed, fire up your terminal and execute,
|
|
Default shell
Whenever you fire up your terminal, do you find zsh? If yes, then zsh
is your default shell. Alternatively, run the following command,
|
|
If your output is /bin/zsh
or /usr/bin/zsh
then, zsh is your default shell.
So how do you make zsh your default? run the following command,
|
|
Don’t have the admin privilege? Check this thread then.
don’t forget to re-login (log out and log in) to change effect. Don’t I need to restart 🧐?
We don’t do that here 😅
Antigen Installation
Installation
No big deal, just run the following command,
What will this command do? 🧐
Go to your home directory(/home/$USER/
), you’ll find a new file, named antigen.zsh
. We’ve no business with this file, so let’s forget, it exists in our system 😆.
Believe it or not, antigen is now installed 😅. Now we just have to modify .zshrc
file in our home directory. Everything will depend on it! ✨
zshrc file
This is the file associated with ZSH. It exists on your home directory and it’s a hidden file because it’s name starts with a dot/ period (.
).
Go to your home directory and look for this file. To show hidden files you have to enable it. Default shortcut is ctrl + h
, I think 🧐. And if you’re using terminal, then you’ve got ls -a
command. 😅
If this file doesn’t exit then open a terminal and if zsh is your default shell then you’ll be prompted with something strange 😅. No need to worry, just press 0 or skip that part. Cause we’re gonna destroy it later 👿.
Now open .zshrc
file with our favorite text editor, and prepare for the worst 🎃.
Copy the following lines to your .zshrc
file,
|
|
Antigen Usage
understanding zshrc
To make it simple, let’s say whenever you fire up your terminal, whatever zshrc contains will be executed. How kool is that?
That means whatever we’ve added to our .zshrc
will also be executed?
- yes
And can we run those lines without using .zshrc
?
- yes 👿.
But make sure to run
source ~/antigen.zsh
first. Cause, you know, we’ve installed our antigen toantigen.zsh
.
understanding antigen
Now it’s time, let’s see what’ve done so far in .zshrc
. We’ve first used this line to show him the location of antigen.
|
|
Then, we’ve loaded oh-my-zsh library (the most popular one for zsh).
|
|
.zshrc
file. But yeah! You can run it for sure. It’ll work until you close your current terminal/ session. In this way you can check a command before putting into .zshrc
.As we’ve oh-my-zsh now on our hands, who can tell us to stop 😅? Now we can easily load oh-my-zsh bundles using commands like,
|
|
And let’s not forget oh-my-zsh themes. In the above example (.zshrc) we’ve used robbyrussell
. And you can change it for sure! check,
Let’s say, you want to install the theme, named refined. Then you can modify the .zshrc
file and set theme to refined
.
|
|
Plugin installation
Now you may want to install custom antigen plugins from various GitHub repositories. And if you don’t know what to install, here’s a list you can try,
zsh auto notify
For now let’s install two most common and interesting plugins! First one is zsh-auto-notify
. Whenever a long process is finished you will get a notification through notify-send
. Check it’s repository,
Now how can we install it? Simple! Check the URL of GitHub of this repository. It’s,
https://github.com/MichaelAquilina/zsh-auto-notify
We’ve to collect the username/repository-name
. For this case it’s MichaelAquilina/zsh-auto-notify
. Then to install it we have to put the following line to our .zshrc
,
|
|
zsh-autosuggestions
Similarly let’s install one more called zsh-autosuggestions
. It’s repository’s link is,
https://github.com/zsh-users/zsh-autosuggestions
So, to install we’ve to use,
|
|
Repo with different branch
Did you notice the branch name from GitHub for above two commands. It’s master, right?
If your branch isn’t master, then our command will be little different.
Suppose the branch is main
then the command will be like,
|
|
Above command is an example. Don’t run it, or it’ll throw you an error. Suppose in future you fail to install any plugin for errors like,
Error! Activate logging and try again.
Then be sure to check the branch name of that repository.
Optimization and plugin settings
Let’s say you’ve installed some plugins to test and then you decided not to use them. So you removed them from .zshrc
. But the files?
Did you notice there’s a folder in your home directory now called .antigen
? This is where all of your plugin exits. If this folder or directory doesn’t exist then whenever you’ll fire up the terminal, it’ll be automatically be created. So what’ll you do to optimize your space?
- Just delete the directory 🫠.
.antigen
directory(unless you customize plugins). Just avoid it! It’ll be created automatically, as long as antigen.zsh
exits and your zshrc knows how to use antigen! 🎃Now, what about the plugin settings?
- Discover the
.antigen
directory and you’ll find corresponding plugins. And then I think you can follow along their official documentations!
Uninstallation
To uninstall ZSH, uninstall from your package manager. Then what about antigen? Here antigen isn’t a package. So you can just go to your home directory and remove .antigen
directory, .zshrc
and other zsh stuff and finally antigen.zsh
.
Wrapping up
Now I think, you’ve successfully installed antigen and zsh with a good looking theme. If you’ve messed up or couldn’t follow along, here’s my .zshrc
after this tutorial.
|
|
If you’ve any questions or queries or any doubt, feel free to contact me or maybe our telegram group 😅. And if you don’t like ZSH there is also fish. Maybe I’ll write another one for fish, who knows? 😆
Thanks for reading this far.
- List useful ZSH plugins
- List useful
alias
for zsh
I’ll really appreciate your help