Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

Time:2022-5-27

Hello, I’m Qiu Feng. The tool I’m going to bring you today is an NPM tool I wrote recently. MMT is based on MacOS + iterm2. The main purpose is to improve the efficiency in daily life. Next, I’ll show you some common scenes.

Scenario 1:Single item multi warehouse

I don’t know if you have ever encountered such a scenario. When your project has two warehouses at the front and back ends, you always need to remember multiple commands or directories, and you need to open multiple terminal windows. For example, when I develop “wood and resume”, I have such a problem. It is a very repetitive action, but I have to enter it every time I develop itPath + start command, the repetition of these steps is completely unnecessary.

The above is the pain point of the first scenario I developed MMT. After using MMT, you can save the above trivial processes. Here is an example:

Your front-end project path: path / case1 front start command: NPM run start

Your backend project path: pathcase1 backend start command: NPM run dev

Use MMT to declare:

> cd path/case1-front

> mmt add case1 start

> cd path/case1-backend

> mmt add case1 dev

Run in any command window

> mmt run case1

The effect is as follows:

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

You don’t have to enter those boring and repeated commands anymore.

Scenario 2:Multi project and multi warehouse

When you maintain multiple technology stack projects by yourself, the startup command is always easy to be confused. Using Vue project startup command may benpm run serveHowever, using react project isnpm run start, some projects may also benpm run dev。 Using MMT can smooth out this difference, and you don’t have to remember your project path.

for instance:

Your project 1: projec1 Vue, start commandnpm run serve

Your project 1: projec2 react, start commandnpm run start

Use MMT to declare:

> cd path/projec1-vue

> mmt add project1 serve

> cd path/projec2-react

> mmt add project2 start

In any command window

> mmt run project1

> mmt run project2

The effect is as follows:

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

Scenario 3:Script alias

When you want to run some workflow work synchronously, you can useadd-syncFor example, a local project of mine needs to rely on two container environments e8a47b8aed91 and e0d433a26388. At this time, running MMT will automatically execute the command.

> mmt add-sync project1-dep "docker restart e8a47b8aed91"

> mmt add-sync project1-dep "docker restart e0d433a26388"

In any command window, you can start two docker instances

> mmt run project1-dep

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

In order to make the script reusable to a higher level, you can also export the configuration and share it with your friends.

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

The above is the basic introduction of MMT. For more functions, you can check the GitHub address:https://github.com/hua1995116…

If you think it’s helpful to you, welcome to mention star.

The tool is easy to use. Of course, it should be equipped with a good domain name. I specially bought a domain name MMT that is more in line with the positioning of the tool run

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

Write a tool based on MacOS + iterm2 to automatically open the window and execute commands

Recommended Today

Huawei HMS core installation pop-up window cannot pop up on third-party mobile phones

Problem description Recently, after accessing Huawei game SDK version 6.1.0.301, we started the game on non Huawei mobile phones and found that the 907135003 error code was always reported after calling the init interface. Test initialization on Huawei mobile phone is successful. problem analysis I contacted Huawei technical supportWork order consultation)。 Reproduce the problem, take […]