DEV Community

Discussion on: Automatically Open the Current Directory in VS Code From Terminal

Collapse
 
scrabill profile image
Shannon Crabill

A hot tip though using open is that you can pass anything to it and it'll behave like you clicked that thing in the GUI, even URLs. So on a Mac, you could do open dev.to and it'd open in your default browser. Since VS Code registers itself as the handler for vscode schemes, you can also do this:

open 'vscode://file//Users/myusername/projects/myfile.txt:123:45'
Enter fullscreen mode Exit fullscreen mode

And it'll open VS Code with the file /Users/myusername/projects/myfile.txt and your cursor already on line 123 and column 45. This is how those error messages that say things like "syntax error at line 20" get to magically work in some cases.

Whooooooooa I did not know you could get this specific with open .. This should be it's own blog post.