Software Engineer at Supabase
March 13, 2024
Oh-My-Zsh simplifies the process of adding custom aliases to your Zsh configuration. Let's explore how to do this using Vim, a powerful terminal text editor, and how to edit the alias file visually:
Open a terminal and go to the custom
directory within the Oh-My-Zsh configuration:
# bash
cd ~/.oh-my-zsh/custom
Inside the custom
directory, create a file to store your aliases. For example:
# bash
touch aliases.zsh
Open the file with Vim:
# bash
vim aliases.zsh
In Vim, press i
to enter insert mode. Add your custom aliases to the file:
# bash
# ~/.oh-my-zsh/custom/aliases.zsh
alias ll='ls -alF'
alias myalias='some_command'
After adding aliases, press Esc
to exit insert mode, then type :wq
and press Enter
to save and quit Vim.
If you prefer to edit the file visually using a GUI text editor, you can open the file with the default editor:
# bash
xdg-open aliases.zsh # This command works on Linux with XDG
# bash
open -e aliases.zsh # macOS
# bash
start aliases.zsh # windows
Finally, apply the changes by reloading your Zsh configuration:
# bash
source ~/.zshrc
Your custom aliases are now ready to use. Test them in the terminal:
# bash
ll
You should see the result of ls -alF
.
Hope this was helpful.