I'm trying to get the currently selected directory path in vscode as a variable from inside my tasks.json
like below:
{
"label": "Echo selected directory from explorer",
"type": "shell",
"command": "echo",
"args": [
"${selectedExplorerDirectory}",// Should return the path of the selected folder from the explorer
],
"problemMatcher": []
}
As for the predefined variables doesn't offer the possibility to get the selected directory path from the explorer. It only offers variables like ${cwd}
or ${workspaceFolder}
which returns the project folder. Also ${relativeFileDirname}
only returns the path of the currently opened file, which is not what I'm looking for.
Is there any way to obtain the currently selected directory as a variable so I can use it in the tasks.json
file?
After the answer of @rioV8 I decided to create and publish my own VSCode Extension called AngularExplorerContext which adds two new options to the explorer context menu when right-clicking on a folder.
It eliminates the need of typing the ng generate
command in to the terminal and the usage of this extension is pretty much straight forward.
I meanwhile also added a second context option to be able to add arguments to the generation process and the NG Types from the dropdown can now be customized using the settings window of VSCode.
I hope this will help anyone in the future trying to improve their workflow with the ng generation process.
The extension can be found on the official Visual Studio Marketplace. Feel free to let me know if you come across any issues so I can make improvements to this extension!