zsh installation:
zsh aliases:
The .zshrc file exists in the user home directory where ZSH aliases are configured. These aliases are loaded automatically when the shell starts, but you can force them to reload through sourcing the .zshrc file.
Alias basic syntax:
- “alias” for the alias keyword
- “Flag” for adding a flag
- “Custom-alias” for setting custom alias
- “Command” entering a command for the custom alias
Simple zsh aliases:
A simple zsh alias is a shorter form of a long command. For creating a simple alias, utilize any text editor such as “nano” in your Linux system and edit the “./zshrc” file. To make editing easier and avoid confusion, keep all of your zsh aliases in one file section.
Here is the syntax for creating a custom zsh aliases:
In the following example, we will set some zsh aliases for making the git repositories work.
alias ginit="git init ."
alias gc="git commit -m 'initial commit"
Now, save this “./zshrc” file and then write out the below-given command for making changes.
Now, initialize a git repository and check out the output.
zsh myip alias:
Add the following line to your “./zshrc” file to print out the current public IP address value. This line will create a zsh alias for the “myip” command.
$ myip
zsh reload alias:
Do you also forget the method of reloading the zsh terminal? Then, no worries!. You can create a zsh alias for reloading your zsh terminal.
zsh update packages alias:
In the “./zshrc” file, to add an alias for updating the packages list, utilize the below-given command.
Now use this alias in the terminal and check the output in the terminal.
Conclusion:
Aliases are an essential part of any Linux shell, and ZSH lets you customize your aliases according to your requirement. You can also use zsh aliases to make the workflow easier. This article provided you with various forms of zsh aliases: simple zsh alias, update packages alias, reload terminal alias, and myip alias. Once you grasp the idea of making zsh alias in zsh, then it won’t be difficult for you to experiment with it.