Setting an alias because it is troublesome to enter "docker-compose" every time

Every time you use docker-compose

docker-compose up
docker-compose down
docker-compose run web~~~

You have to enter, which is very troublesome, isn't it? It's very easy to type just by adding a little description to .zshrc, so if you haven't set it yet, please set it now.

environment

・ Mac OS ・ Zsh

manner

Anywhere, so in .zshrc

alias dc='docker-compose'

Just add the description of. Let's do it right away.

First, start the terminal and on the root directory

ls -a

Type the command to display the folder list and check if .zshrc exists. If you are using zsh, it should basically exist.

After confirming the existence of .zshrc,

code .zshrc

Use a command that opens a visual editor, such as, to open the .zshrc edit screen. code ~~ is a command to open VScode, so if you are using another editor, enter the appropriate command for that editor.

Example) If you are using Sublime, subl .zshrc

If you open the editor, it's OK anywhere, but for the time being, at the bottom

alias dc='docker-compose'

Add the description of.

This is a description that specifies an alternative command called an alias, so it does not necessarily have to be "dc", you can specify your favorite alias by referring to the following.

alias Favorite alias='docker-compose'

After adding this description, go back to the terminal

source ~/.zshrc

Let's run. This will reflect the previous settings.

Use cd ~~ to change to the directory where the docker-compose file exists, and try starting docker-compose with the alias you specified earlier.

alias dc='docker-compose'

If you make the above settings,

dc up
dc down
dc run web ~~

You can run docker-compose with.

The end

that's all. Not limited to docker-compose, if there are other commands you want to omit, you can specify the alias in the same way as above.

Recommended Posts

Setting an alias because it is troublesome to enter "docker-compose" every time
[Java] I want to make it easier because it is troublesome to input System.out.println.
Library to check if it is an IPv4 format string
Is it an Android app?