Perform cumbersome repetitive terminal commands with few clicks
Tags: vscode, terminal, productivity, tipsandtricks
Published: 2023-10-06 06:42:27

Being a developer, I know that everyone loves to be in the terminal all the time 😍. I mean who doesn't like that blackish background with a blinking little cursor, the hostname in green color, and those sweet sweet commands! (Uh oh! I think romantic me has kicked in 😅😬 Back to the topic). So, I know how cool it looks to be using the terminal all the time, but we hate it switching to the terminal for some basic regular tasks 😓, like starting the server, deploying stuff, checking the logs, etcetra etcetra...😪

What if I tell you, we can have a button to make it all possible with just a single click? How cool it will be to just click on the button and woosh! It's done!😉 Okay, if you've imagined till this way...let's add some more spice to it! What if I tell you, you can use it directly using your favorite text editor? You guessed it right! VS Code!

"Enough of the showreel Avinash! Let's get to the business🙄" - Okay Okay, so let's learn what things you'll need to do in order to have the same spell in your system!

VSCode extension Quick Task
tasks.json file in the directory
So, let me tell you the spell on how to do this magic trick on your system, trust me it's really very simple😉.

- Go to the extension section of VSCode and search for "Quick Task". Install it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ktgtjjsx589h97ezf5v.png)
- We now, need to create some tasks in VSCode for the extension to pick them up. So, open the command palette by clicking the combination of Ctrl (Command for Mac) + Shift + P.
- Type in "task" and select "Configure Default Build Task".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcjb2o6ddbbieuzrfzqj.png)
- You'll see an option to create a custom task, select it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8trpzxjklomiq6rtno0b.png)
- You need to tell the type of command the task will perform. We can choose "Others" in this case, as we are going to automate some shell commands.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hz59qhgx231pdrdciht.png)
- Now, a file named tasks.json will be created containing all the tasks. You can add label, command and leave the type to be shell.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wiml6w84odolnc7ez3x2.png)
- Enter the shell command you want to automate and it's done! Reload your VSCode for the extensions to pick up the tasks from tasks.json.
- You'll see an icon in the bottom bar to open all the tasks available in your workspace. It will also, show you tasks from package.json file, if you are using javascript.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbzwlt8otcgp5pf68pnz.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9j3u8qex3cac38ma138a.png)

You must be thinking, "Avinash, what if the command requires an input? How to do it then?🤔". Don't worry, I have got you covered!😉

We just need to specify the inputs and use them in our command in tasks.json. It will prompt to take input while running and performing a task.

Here is an example of such a task:-


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fh7du3tkddxipe1mvio4.png)
This example will ask for a commit message from you when you run this specific task. So, you can automate some repetitive tasks that you do daily with these easy steps. Thanks for reading.

Let me know about any shortcomings in the comments below!

Stay tuned for more such tips & tricks!