I am working with the command line executing the same commands many times manually following the same pattern. Now I am looking for a way to simplify it by just typing the command only once.
Lets take a look at a normal docker example:
docker ps
docker ps -a
docker ps -l
docker stop x
docker start x
docker start y
docker logs y
docker logs -f z
This example also applies to many more commands such as git, brew, gulp, gcloud.
Now I am looking for some sort of a command wrapper shell, that allows me to write with docker
that will wraps any command in a nested/sub shell.
Then I don't need to prepend the docker
command and just call:
>ps
# does docker ps and displays result
>stop x
# prepends docker so docker stop x is actually executed
CTRL+C # to exit the command wrapper
Does something like this already exist? I was googling for it but could not describe it properly hence I didn't find anything.
You could also define a function yourself, and include it in your
.bash_profile
or similar:Example usage:
EDIT: This function does not do input sanitization or anything, so use at your own risk etc...
You could write a bash or other shell script to do this. An easy alternative that's almost as good would be just to define short aliases and prepend them, for example
and so on. Then run
and so on, which is hardly more work than typing just the commands.