Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there variables for current file or folder in the VS Code terminal?

When in the terminal pane, I would like to reference the file or folder of the active editor tab via environment variable or PowerShell variable (preferred). Something like this:

ii $vsActivePath

or

ii $vsActiveFile

Is this possible?

like image 832
wtjones Avatar asked Apr 24 '17 15:04

wtjones


People also ask

How do you see variables in VS Code?

Set a breakpoint in your code, and start debugging by pressing F5 or selecting Debug > Start Debugging. When paused at the breakpoint, hover over any variable in the current scope. A data tip appears, showing the name and current value of the variable.

How do you add a path variable in VS Code?

Click the Advanced system settings link. Click Environment Variables. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Reopen Command prompt window, and run your java code.

Does VS Code have a variable Explorer?

After the cell finishes running, you can view the data that was loaded using the Variables Explorer and Data Viewer. First select the Variables icon in the notebook's upper toolbar. A JUPYTER: VARIABLES pane will open at the bottom of VS Code. It contains a list of the variables defined so far in your running kernel.

How do I change the directory in a VS Code in terminal?

Open Visual Studio Code and access the Command Palette (⇧⌘P) and start typing shell command and select option Shell Command: Install 'code' command in PATH. After that you're able to start a new terminal window, change into your project directory and use code . to open the current directory in Visual Studio Code.


1 Answers

Not sure if this is exactly what you're looking for but you can get access to various variables in vs code such as:

${workspaceRoot} the path of the folder opened in VS Code
${workspaceRootFolderName} the name of the folder opened in VS Code without any slashes (/)
${file} the current opened file

Full details can be found here

like image 183
Stephen Wilson Avatar answered Oct 24 '22 19:10

Stephen Wilson