Skip to content

Commit

Permalink
Fully functional! In a basic way, but usable
Browse files Browse the repository at this point in the history
  • Loading branch information
tkellogg committed Aug 5, 2012
1 parent 42d7677 commit 9ed8d41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
11 changes: 7 additions & 4 deletions Jump.Location/CommandController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

Expand All @@ -12,17 +13,19 @@ class CommandController
private bool needsToSave;
private DirectoryWaitPeriod waitPeriod;

public CommandController(IDatabase database, IFileStoreProvider fileStore)
internal CommandController(IDatabase database, IFileStoreProvider fileStore)
{
this.database = database;
this.fileStore = fileStore;
var thread = new Thread(SaveLoop);
thread.Start();
}

public CommandController(string path)
:this(new Database(), new FileStoreProvider(path))
public static CommandController Create(string path)
{
var fileStore = new FileStoreProvider(path);
var database = fileStore.Revive();
return new CommandController(database, fileStore);
}

public void UpdateLocation(string fullName)
Expand Down Expand Up @@ -53,7 +56,7 @@ private void SaveLoop()
}
catch(Exception e)
{
Console.Error.WriteLine("Jump-Location received {0}: {1}", e.GetType().Name, e.Message);
EventLog.WriteEntry("Application", string.Format("{0}\r\n{1}", e, e.StackTrace));
}
}
else Thread.Sleep(0);
Expand Down
9 changes: 4 additions & 5 deletions Jump.Location/JumpLocationCommand.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System.Linq;
using System.Management.Automation;
using System.Management.Automation;

namespace Jump.Location
{
[Cmdlet("Jump", "Location")]
public class JumpLocationCommand : PSCmdlet
{
private static bool _hasRegisteredDirectoryHook;
private static readonly CommandController Controller = new CommandController(@"C:\Users\Kerianne\jump-location.txt");
private static readonly CommandController Controller = CommandController.Create(@"C:\Users\Kerianne\jump-location.txt");

/*
* x1. Figure out how long they stay in the directory
* x2. Log occurences of filename / weight
* x3. Tail matches - search matches beginning of last segment of path
* 4. Make MSI installer for easy use
* x4. Make MSI installer for easy use
* 5. Weighting algorithm - match what Autojump does to increase weights
* 6. Match what Autojump does to degrade weights
* 7. Multiple args - last arg is a tail match, previous args match previous segments
Expand Down Expand Up @@ -43,7 +42,7 @@ protected override void BeginProcessing()

InvokeCommand.InvokeScript(@"Set-PSBreakpoint -Variable pwd -Mode Write -Action {
[Jump.Location.JumpLocationCommand]::UpdateTime($($(Get-Item -Path $(Get-Location))).PSPath);
}", "hello Jim");
}");

_hasRegisteredDirectoryHook = true;
}
Expand Down
7 changes: 3 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ 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. You'll open up a console to `C:\Users\me`
or `C:\Windows\system32` and then issue a `cd C:\work\Website`.
`Jump-Location` is a cmdlet lets you issue a `Jump-Location we` to jump
`Jump-Location` is a cmdlet lets you issue a `j we` to jump
directly to `C:\work\Website`.

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
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 `Jump-Location` to jump further away.

`Jump-Location` is a powershell implementation of
Expand Down

0 comments on commit 9ed8d41

Please sign in to comment.