Boost Your Workflow: Speeding Up Terminal Work with Visual Studio Code and These Simple Tricks
In this article, I show some simple but very effective tricks for speeding up your workflow when working on your terminal.
I often work in Terminal on my Mac. Be it when I connect to a Linux server, use the Azure CLI, run any console programs, or execute certain commands in the terminal to maintain my Mac. I normally work in the terminal that is pre-installed on the computer, and I am fast by using the auto-complete function with the TAB key. However, there are always situations where I don’t remember certain commands, or I have to look them up again. Once I have found them, I copy them from my browser or my personal knowledge base into the terminal. It’s only a few clicks, but it’s always tedious because I have to move my fingers away from the terminal and use the mouse.
One example is when I want to set up an SSH tunnel to my VM in the cloud. This command is quite long and contains an IP address I can never remember. I could search the history of the terminal, but that would take time until I found this command. So, what do I do? I save this long command in my Obsidian notebook. It looks like this:

I copied the command and pasted it into the terminal. Unfortunately, there are two lines, so I repeated the step.

Another tool of my choice is Visual Studio Code. I use it daily to complete various tasks, develop code, create Markdown documents, etc.
Within Visual Studio Code, there is also the option of calling up a terminal. So that I don’t always have to open Obsidian, I can open the Obsidian folder in which the Markdown commands are located in Visual Studio Code. In this example, I have a Markdown file in the Airbyte folder. So I open it with VS Code.

The cool thing about Obsidian is that all notes are saved as Markdown files on the file system. So I can edit and save the data outside of Obsidian and make the changes visible in Obsidian. The view in VSCode then looks like this:

I opened a VS Code terminal and can copy the code from the same program.

This is more comfortable, but not yet perfect. Because I have to use my mouse again, but I would prefer to keep my hands on the keyboard. It would be cool if I could select the commands in the Markdown file, and they would then be executed. I can achieve this by setting up a shortcut in VS Code. This will execute the selected code directly in the terminal with a key combination. To activate this feature, I can use the command palette with
cmd + shift + p

I then search for the setting by typing “Preferences: Open Keyboard Shortcuts (JSON)”.

The JSON file opens, and I can insert and save the following content.
// Place your key bindings in this file to override the defaults
[
{
"key": "shift+enter",
"command": "workbench.action.terminal.runSelectedText"
}
]
If I now select a line in the Markdown file

and then click the combination shift + enter, the code is immediately executed on the console.
Creating and opening files is another task that can be accelerated with VS Code. How often did I want to create a new file to save something or open an existing file? This was again tedious, I had to use my mouse and click through to drag a file into VS Code.
This can be remedied by adding VS Code directly to the PATH variable.
Again, I open the command palette of VS Code with
cmd + shift + p
and then search for “code path”.

I then receive the success message

and can get started straight away.
As a test, I will create a file called “text.txt”. All I have to do is add the command “code” in front of the file name. When executed, the new file opens immediately in Visual Studio.

Insert a sample content, save, and close. If I execute the code again, the existing file is opened.

If you liked this post, please show your support by 👏 for this story and follow my profile. Thank you for reading!