Hello I'm trying to make an alias in zsh for the following command:
gcloud compute instances delete CONTAINER_NAME --zone=x --quiet
How can I make an alias that would fit my parameter in the CONTAINER_NAME ?
Monterey 12.2
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityHello I'm trying to make an alias in zsh for the following command:
gcloud compute instances delete CONTAINER_NAME --zone=x --quiet
How can I make an alias that would fit my parameter in the CONTAINER_NAME ?
Monterey 12.2
zsh
supports functions, so you can put the following into the appropriate startup file
function gcloud_delete() {
gcloud compute instances delete "$1" --zone=x --quiet
}
and then (after sourcing that file) run
gcloud_delete CONTAINER
Have a look at oh-my-zsh project.
You have a plugin called aliases. With it, you're able to define aliases using arguments.
To edit the aliases file:
code ~/.oh-my-zsh/custom/plugins/aliases/aliases.plugin.zsh
In that file you can create an alias like this:
gcInstanceDelete="gcloud compute instances delete $1 --zone=x --quiet"
And call the alias with:
gcInstanceDelete CONTAINER_NAME