0

I'm looking for a functionality similar to wd with ZSH where you can add a "warp point" A and then use wd A to change to that directory. I searched for something like this but I wasn't successful. Maybe, I didn't use the proper key words..

Any idea of a plugin that provides similar functionality in powershell?

Destroy666
  • 12,350

3 Answers3

0

The closest matches to this feature are listed in the post Create a folder alias in PowerShell :

Turn a folder into a new PowerShell drive with New-PSDrive :

New-PSDrive foo filesystem 'C:\Program Files'
New-PSDrive bar filesystem 'foo:\Microsoft'
cd foo:

To persist between sessions you could add them to your profile script ($profile).

But of course you can also cd to a folder from a variable

$foo = 'C:\Program Files'
$bar = Join-Path $foo 'Microsoft'
cd $foo

Write a function that cd's to that directory

For instance, put the following function in profile.ps1:

# quickly cd to folder
function <short name> {
    cd <path to directory>
}

Then, in PowerShell:

PS> <short name>
harrymc
  • 498,455
0

You can also simulate such functionality with a global HashTable. Example:

$mdirs = @{
  git = "D:\Something\git"
  docs = "C:\Users\Bob\Documents"
  art = "F:\Art"
}

Call e.g. $mdirs.git to get the value. This has an advantage of you being able to call $mdirs to see all the definitions, there's also Tab completion.

For it to be global/permament, you need to add it to your profile, which is required also by pretty much all other solutions. You can enter $PROFILE in your PowerShell console(s) to know where their profile files reside, it differs per version.

The disadvantage is that you need to edit the file for any future changes. A fully dynamic solution wouldn't be too hard to code though. You could just write few functions that add/read/remove unique aliases to/from a file and then in profile use the read function to set up either a HashTable or anything else.

Destroy666
  • 12,350
0

I created a version of warp-directory as a PowerShell module:

https://github.com/jrmitch120/warp-directory