简体   繁体   中英

How To Create Custom Terminal Command for VS Code

I use git (like most people) for my projects in VS Code. However, I find it a hassle to first add the files, then commit them. So what I want to do is create a terminal command (maybe like commit "message" ). What this command should do is run the following: git add . then git commit -m plus the message they wrote in the command. From what I've seen, this shouldn't be too much of a hassle.

Thanks in advance!

You can add these commands as a script in your package.json. To get access to the command line if your package.json is used in a Docker container you use -bash in front of your script, otherwise not necessary as far as I know.

To run the script you use npm run name-of-my-script .

You can also collect your command line instructions in a bash file and run the file from package.json as discussed here: Running bash scripts with npm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM