• Stars
    star
    469
  • Rank 93,595 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Powershell `cd` that reads your mind

This project is not actively maintained. Please consider using its successor ZLocation.


Jump-Location: A cd that learns

If you spend any time in a console you know that cd is by far the most common command that you issue. I'll open up a console to it's default location in C:\Users\tkellogg or C:\Windows\system32 and then issue a cd C:\work\MyProject. Set-JumpLocation is a cmdlet lets you issue a j my to jump directly to C:\work\MyProject.

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-Location as a replacement for cd. Use cd to go local, and use Set-JumpLocation to jump further away.

Jump-Location is a powershell implementation of autojump.

How it knows where you want to go

It keeps track of how long you stay in a directory and builds a database. When you use the Set-JumpLocation or j command, 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:

  • j de -> C:\Users\tkellogg\code\Jump-Location\bin\Debug
  • j doc -> C:\Users\tkellogg\Documents

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 jumpstat looks like this:

255    C:\Users\tkellogg\code\Jump-Location\bin\Debug
	50     C:\Users\tkellogg\code\MongoDB.FSharp\bin\Debug

Using j de will jump to Jump-Location\bin\Debug. But use something like j mo d if you really want to go to MongoDB.FSharp\bin\Debug. You can issue a j mo d. mo matches MongoDB.FSharp and d matches Debug.

j internally calls Push-Location, so you can navigate back in your visited locations stack with popd or special Jump-Location query j -.

Quick Primer on jumpstat

You can use jumpstat to 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) jumpstat returns 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[10].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 -All option 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 . 

Installation

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:

Install-Module Jump.Location

There is also a Chocolatey package for Jump-Location. To install via Chocolaty

choco install Jump-Location

Otherwise you can still install it manually.

  1. Download the latest release.
  2. Open properties for zip file and click "Unblock" button if you have one.
  3. Unzip
  4. Open a PowerShell console
  5. Run .\Install.ps1. You may need to allow remote scripts by running Set-ExecutionPolicy -RemoteSigned. You may also have to right-click Install.ps1 and Unblock it from the properties window. Alternative: Add line Import-Module $modules\Jump-Location\Jump.Location.psd1 to your $PROFILE, where $modules\Jump-Location is 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 j and jumpstat aliases.

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:

  1. Copy the file to a FAT32 file system (such as a memory card) and back.
  2. Run cmd /c "echo.>Jump.Location.dll:Zone.Identifier"

If you find any bugs, please report them so I can fix them quickly!

Build from source

From root directory:

  1. Run msbuild .
  2. Run .\copyBuild.ps1

In directory Build you will have local build of module.

TODO

  1. Local search. j . blah will only match dirs under cwd. Using . will also search outside the DB.
  2. Better PS documentation

References

  1. old releases.

More Repositories

1

dura

You shouldn't ever lose your work if you're using Git
Rust
4,264
star
2

fossil

A mastodon client optimized for reading, with an AI-enabled algorithm for displaying posts
Python
65
star
3

MongoDB.FSharp

Silent utilities to make the official MongoDB driver feel natural to work with in F#
F#
64
star
4

objectflow

Lightweight workflows in .NET for busy developers
C#
64
star
5

rust-mqtt

A MQTT client in Rust
Rust
26
star
6

alljoyn-examples

Copy & paste of Android examples from the AllJoyn repository for use at Cloud Identity Summit 2014
Java
9
star
7

syndr

Blog on the #fediverse
Rust
8
star
8

enyaml

A YAML parser for .NET
C#
8
star
9

Raft-JVM

A raft implementation for the JVM
Java
7
star
10

objectflow-example

An example project for using objectflow
JavaScript
5
star
11

mqtt-resource-directory

A spec for a Resource Directory implementation for MQTT
4
star
12

comboEditable

turn a <select> box into an editable drop down list with this jQuery plugin
JavaScript
3
star
13

Trappings

Test fixtures for C# and MongoDB
C#
3
star
14

tkellogg.github.com

my blog
HTML
2
star
15

NetLint

A quality tool for testing conventions in .NET web apps & libraries
C#
2
star
16

FunctionalFlashcards

A sample ASP.NET MVC app in F# (with a little C# in the Razor views)
JavaScript
1
star
17

Cortez

A fast object-to-object mapper that can generate Linq queries
C#
1
star
18

alljoyn-core

Pushed AllJoyn-Core to Github for easier code viewing on July 18, 2014
C++
1
star
19

ReflectionPropertyInvokeBenchmark

Test for performance in setting a property in C# via several different strategies
C#
1
star
20

hg2hg

utility for converting mecurial repositories
Ruby
1
star
21

NHibernate3-withProxyHooks

A fork of the NHibernate 3.0 release with hooks added into NHibernate.ByteCode.Castle to add extra interfaces and mixins to generated proxies
C#
1
star
22

Natural.NUnit

BDD using NUnit like an RSpec user would expect
C#
1
star
23

ironmine

A .NET/Mono client for redmine
1
star
24

emopoint

Python
1
star