Powershell `cd` that reads your mind
If you spend any time in a console you know that
cdis by far the most common command that you issue. I'll open up a console to it's default location in
C:\Windows\system32and then issue a
Set-JumpLocationis a cmdlet lets you issue a
j myto jump directly to
It learns your behavior by keeping track of how long you spend in certain directories and favoring them over the ones you don't care about. You don't have to use
Jump-Locationas a replacement for
cdto go local, and use
Set-JumpLocationto jump further away.
Jump-Locationis a powershell implementation of autojump.
It keeps track of how long you stay in a directory and builds a database. When you use the
jcommand, it looks through the database to find the most likely directory and jumps there. You should only need to give it a 2-3 character hint. For instance, on mine I can do:
What if you have several projects and you want to get to the Debug directory of one that you don't use very often? If you're
jumpstatlooks like this:
255 C:\Users\tkellogg\code\Jump-Location\bin\Debug 50 C:\Users\tkellogg\code\MongoDB.FSharp\bin\Debug
j dewill jump to
Jump-Location\bin\Debug. But use something like
j mo dif you really want to go to
MongoDB.FSharp\bin\Debug. You can issue a
j mo d.
Push-Location, so you can navigate back in your visited locations stack with
popdor special Jump-Location query
You can use
jumpstatto see what's in the database. In tradition with
autojump, the database is saved to
~\jump-location.txt. You can open up that file and make changes. The file will auto-load into any open powershell sessions.
Since we're in Powershell (and not legacy Bash)
jumpstatreturns objects. This means that you don't ever have to know anything about
~\jump-location.txt. You can manipulate the objects it returns. For instance, this is valid:
PS> $stats = jumpstat PS> $stats.Weight = -1 PS> jumpstat -Save
Setting a weight to a negative number like that will cause it to be blacklisted from all jump results. Use the
jumpstat -Alloption to see negative weights included in the jumpstat result set.
When you remove/rename directories, Jump-Location database can become out of sync with the file system. Your top-choice will pointed to an invalid location. You can cleanup database with
jumpstat -cleanup. It will remove all records with non-existing paths.
Jumpstat can also be used with the "scan" parameter (jumpstat -scan) to recursively scan sub-directories into the database with 0 Weight. This is a quick way to teach Jump-Location about related directories without having to manually cd'ing to each one individually.
Add all subfolders of the current directory:
jumpstat -scan .
Important: Jump-Location requires PowerShell version 3 or higher. Older installations of Windows 7 may only have PowerShell version 2. How to update powershell.
Recommended: Install from psget.net:
There is also a Chocolatey package for Jump-Location. To install via Chocolaty
choco install Jump-Location
Otherwise you can still install it manually.
.\Install.ps1. You may need to allow remote scripts by running
Set-ExecutionPolicy -RemoteSigned. You may also have to right-click
Install.ps1and Unblock it from the properties window. Alternative: Add line
Import-Module $modules\Jump-Location\Jump.Location.psd1to your
$modules\Jump-Locationis a path to folder with module.
Next time you open a PowerShell console Jump-Location will start learning your habits. You'll also have access to the
If you get errors after installation, try unblocking the file Jump.Location.dll manually by one of the following methods to clear the "untrusted" flag:
If you find any bugs, please report them so I can fix them quickly!
From root directory:
Buildyou will have local build of module.
j . blahwill only match dirs under cwd. Using
.will also search outside the DB.