I'm facing an issue with an alias for zsh
.
I've this alias in my .zprofile
file: alias cleanimg="for i in `docker images | grep '<none>' | awk '{print $3}'`; do; docker rmi -f $i; done"
.
When running cleanimg
from my terminal I'm getting this error: zsh: parse error near `do'
.
I tried to remove the ;
right after the do
keyword but it didn't fix the issue.
However, that alias runs correctly if I execute the code directly from a terminal.
Can anybody help me with this syntax error?
Thanks by advance.
If all you want is to clean your docker images, you can set an alias like this:
alias cleanimg='docker rmi -f $(docker images -q -f "dangling=true")'
The sub commande docker images -q -f "dangling=true"
return all your id to remove and since docker rmi
accept arguments you can pass them directly