Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell: VSCode, file, => go to parent path in powershell console?

Hi,

When, in Visual Studio Code, I need to run a PS1, I obviously need to go (in the VSCode Powershell console) to the path of the file first.
F.e. path is c:\whateverfolder\folder\folder\anotherfolder\scripts\main.ps1
What I do is, select file, right mouse, "copy path", then copy path, paste it into the console remove the filename, and cd to it
=> cd c:\whateverfolder\folder\folder\anotherfolder\scripts\

There has to be an easier way right? Isn't there an option to "go to parent path of file"?
User generated image
Please advise,
J
Avatar of Bill Prew
Bill Prew

Are you trying to run the PS script you are editing in VSC?  If so, why not use the PowerShell - Visual Studio Marketplace extension?


bp[/b]]
»[b
Avatar of janhoedt

ASKER

Obviuously using that extension. What is that related to my question? It does not have the option 'go to parent path' on a ps1 file
If you have the .PS1 file open, you can just press F5 to run the script.

You don't have to have the current directory in the terminal set to the location of the script, you can just provide the full path to the script, or the relative path to script (i.e. relative to the current directory).  For example, if the current directory is c:\temp\child and the script is located in c:\temp, you could use either of these:
 - c:\temp\script.ps1
 - ..\script.ps1
(remember, "." is current directory, ".." is parent directory)
I dont think you understand my question, please read it and see screenshot. Specifically the text in red.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No answer, please close ticket.
The console here extension in VSCode opens (with ctrl + rightmouse on folder) the folder location.