Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    VS Code Command Line Tips and Tricks

    John LindquistJohn Lindquist

    VS Code allows you to install a code command into your PATH so you can launch code a few different ways. You can open projects, create files in memory, or even pipe the results of other commands into code.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: Go into your command palette. The default shortcut is Command+Shift+P, but I changed it to Command+T instead. Type out "Show command, install code command in path." Then, you should get a notification saying that that worked.

    Then in your terminal, you can type code, and then a path, so projects, proxy lessons, so a path to a project, hit enter, and then code'll pop up that project with that directory opened. That's very handy after you get clone or create any new project from a command line tool.

    You can also tell code to create some files somewhere. I'll try fu/bar/somefile.js. This will pop open code in whatever project is currently open. You see my proxy lessons project is open. I can type in some JavaScript here and all the highlighting will work.

    Back to my terminal, if I try to cd into fu, you can see that fu doesn't exist. As soon as I save this file in code and go back, I can cd into fu, cd into bar, and then check this directory. You'll see some file is there. You can also pipe content into code. If I go, "Hello," and then pipe code and add a dash, hit enter there. Code will open up with "Hello" as the output.

    For example, if I were to list and then pipe that into code, you can see it'll list some file that we created or if I were to curl the GitHub API, so GitHub.com, then pipe that into code, hit enter, you can see it'll download that file and pop it open inside of code.

    If you're not seeing the proper highlighting, if you open your command palette and type in "Language," you should see change language mode as an option. I'm going to type "JSON," for this file. Hit enter, and then you'll get the proper JSON highlighting and tools.