CodeNewbie Community 🌱

Aaron McCollum
Aaron McCollum

Posted on • Updated on • Originally published at codingwithaaron.wordpress.com

Three nifty shortcuts on the Command Line

The command line is a very useful tool to use to navigate and perform actions on your computer. You can find it by opening the ‘Terminal’ application on your Linux or Mac computer, or by opening the ‘Command Prompt’ or ‘Powershell’ applications on your Windows machine. Today’s article will only apply for Linux and Mac users and will not be written for Windows users (since the command vocabulary and syntax will be different).

Here are three shortcuts that are useful using the command line:

  1. Typing in a period “.” is a shortcut for opening all the files in the current directory you are in. If you navigate to your project folder and type code . it will open all the files at once in VS Code (if VS Code is downloaded). This is useful when you are opening your project to continue working on it – why click on all the multiple files once at a time on your GUI when you can open VS Code and all your files at the same time?

  2. You can automatically open VS Code by typing code in your terminal. This should be automatic for Linux users, however for Mac you can set this shortcut up by opening VS Code, using the cmd+shift+p combination to open up program commands, and clicking Shell Command: Install ‘code’ command in PATH. This will allow you to open VS Code on Mac with the code command in your terminal.

  3. Using the tab key can auto-complete the command in your terminal. This only works once you have typed in enough information manually for the terminal to have only one option to choose from. But this can save you time and potential headaches by reducing typing errors in your terminal.

  4. Bonus! You can create multiple files at once by using the touch command with various new file names after it. You will need to separate out each new file with a space. If you are just starting web development, this is a great shortcut for creating your HTML, CSS, and JavaScript files at the same time. Example: touch index.html style.css script.js

I’m still at the beginning of learning the terminal, however I found these shortcuts to be pretty awesome and will be inserting all of them into my work flow this week. If you have any additional shortcuts, I’d love to hear about them!

Top comments (8)

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

Tips 1 & 2 also work on Windows CMD - 3 works for file paths.

On Powershell all 3 work 🥳 (The bonus doesn't work on either because no touch command 😢)

Forem tip: Instead of starting your post with "Originally posted on my blog" with a link, you can use canonical_url: https://codingwithaaron.wordpress.com/2021/08/28/three-nifty-shortcuts-on-the-command-line/ to create a linkback to your blog which has SEO benefits for your blog 🥳🥳

Collapse
 
aaron profile image
Aaron McCollum

@terabytetiger Hey there, me again! I haven't figured out how to use the canonical URL. I posted the command in the parenthesis, however instead of having it go to my sight, it went to a 404 error. Would you happen to know where I can include the canonical URL?

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

The Canonical URL has to get set in the frontmatter - if you're using the v2 editor it'll look something like this:

Version 2 editor for forem with the settings cog opened showing a spot for canonical url

If you're using the v1 editor it'll look more like this:

V1 editor for DEV showing a canonical url in the frontmatter

Then you can remove your line linking back to your post since there will be an auto generated link at the top of the article:

A Post on DEV with a canonical url linkback to the originally posted site.

Thread Thread
 
aaron profile image
Aaron McCollum

Mind officially blown! I have the V2 editor it looks like. That's incredible, thanks so much!

Thread Thread
 
terabytetiger profile image
Tyler V. (he/him)

I forgot that the V2 editor didn't use frontmatter the same way, which probably induced the initial confusion 😅 I'm glad I could clear it up though! 🥳

Collapse
 
aaron profile image
Aaron McCollum

Thanks for the Windows info! And I will try that with my next post later today. Appreciate the heads up on the linkback - that’s clutch!

Collapse
 
aaron profile image
Aaron McCollum

You’re welcome Vanza!