The token '&&' is not a valid statement separator in this version in vs code terminal

Viewed 419

I get an error when I try

 mkdir python && cd python && echo python > index.py

in my VS code terminal. This is the tutorial I am following. here

2 Answers

Unfortunately I don't think we have such a thing as && chain operators in Windows PowerShell, would be nice though. This is pretty close to what you're looking for, it is a lot more verbose as you can see.

Note, mkdir is an alias for New-Item.

$folder = New-Item python -ItemType Directory
if($?){ Push-Location $folder; 'python' > index.py; Pop-Location }

Based on Mahmoud Moawad's answer, if you're running PowerShell Core:

New-Item python -ItemType Directory -Force 1>$null && Push-Location python && 'python' > index.py && Pop-Location
Related