Windows Powershell: Shortcut for change directory
There is also another way to do this:
function PP { cd C:\Users\Username\Dropbox\Websites\2014\Projects\ProjectName }Set-Alias shortcut `PP`
new-psdrive is your friend :
New-PSDrive -Name docs -PSProvider FileSystem -Root "C:\Users\username\Documents"cd docs:
Run this in powershell:
start notepad $profile
That will open up your profile in notepad (notepad will prompt you to create it if it doesn't exist).
Any code you write in this .ps1
file will be executed when powershell starts.
You can also set a system environment variable, like if you were to set MYPSPATH
equal to C:\Users\Username\Dropbox\Websites\2014\Projects
then you could do this:
cd $env:MYPSPATH
That could be done either manually each time, or automatically within your $profile
.
Also it's unclear from your question, but it sounds like you're doing a cd
for every path component.
There's no need to do that. This command that you wished for:
cd C:\Users\Username\Dropbox\Websites\2014\Projects\ProjectName
will work as is. If I misunderstood this point I apologize.
Something that also might be useful to you is pushd
which is an alias of Push-Location
. This lets you change to a new directory and easily revert back where you started with popd
or Pop-Location
.
PS C:\users\Xenostar> Push-Location .\Dropox\Websites\2014\ProjectsPS C:\users\Xenostar\Dropbox\Websites\2014\Projects> Pop-LocationPS C:\users\Xenostar>
And you can push multiple levels deep, and keep popping back to the previous ones.