In my .zshrc I tried to make a few aliases .I looked into a lot of places, but I couldn't find out a way that worked. I used this code below:
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run alias. # # Example aliases
alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"
alias n= "nano"
alias m= "mkdir"
alias w= "cd ~/Documents/UoMWorkspace/Semester2"
alias j= "cd ~/Documents/UoMWorkspace/Semester2/COMP17412"
Then I wrote a command source ~/.zshrc
. Still it didn't resolve the issue. I get error messages like zsh: command not found: j
Could anyone help me with any suggestions and let me know what am I doing wrong?
Best Answer
There must not be any whitespaces around between
=
and either alias name or alias definition:BTW: If you are looking for a way to shorten directory names, I suggest looking into Named Directories and the
AUTO_CD
option instead of aliases:This allows you to use
~w
instead of~/Documents/UoMWorkspace/Semester2
and~j
instead of~/Documents/UoMWorkspace/Semester2/COMP17412
(or~w/COMP17412
). Socd ~j
is identical tocd ~/Documents/UoMWorkspace/Semester2
. It also works as part of a path, e.g.cat ~j/somedir/somefile
.With
zsh
will automaticallycd
to a directory if it is given as command on the command line and it is not the name of an actual command. e.g.