Terminal magic with Fish shell functions
I have an issue: I have to login to AWS ECR and push images multiple times a day and I hate it. I always get the command wrong, mistype the path or forget to use the new
--no-include-email flag — get-login docs.
This is why I decided to add a function that will do just that: get login credentials from ECR.
The output of this command is actually another command, which is used to log me into my container registry. It looks like below:
That is the standard docker registry login command, and I need to execute it. I could just manually do a copy+paste with it, but I’m too lazy, so I pipe it through the fish shell interpreter.
ecr-login us-east-1 | fish
This way, when
ecr-login finishes, and returns the docker login command, that automatically gets piped through the interpreter, which in turn, executes it.
Finally, here’s the whole “picture”.