Question

In bash, we can use shopt -s expand_aliases to expand aliases in scripts.

What are the equivalent commands for zsh, csh, and tcsh? Do they even exist?

In focusing my efforts on zsh, I haven’t found such a command. I even tried sourcing the file with the aliases inside the script, but it did not work.

Was it helpful?

Solution

For zsh you can use setopt aliases

#!/usr/bin/zsh

alias hoo="echo bar"
unsetopt aliases
hoo # outputs `./test.zsh:5: command not found: hoo`
setopt aliases
hoo # outputs `bar`

see man zshoptions for detail.

For csh and tcsh, sourcing the files (source ${HOME}/.cshrc, for example) suffices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top