/WarpDrive

Warp across directories

Primary LanguageJavaMIT LicenseMIT

WarpDrive - Warp across directories

All Contributors

WarpDrive is a replacement for cd (However it does use cd to work). It tracks your visited directories and uses a "frecency" algorithm (combining frequency and recency) to determine which directory to warp to.

Example Usage

Usage

You can use WarpDrive like this:

wd someDir

If you had visited someDir before (and thus someDir is in the datafile), it'll take you there. Otherwise, it'll just pass on the aguments to cd (which means that both relative and absolute paths work).

You could also do the same thing with just parts of the full path:

wd s

or

wd Dir

Options

Currently, WarpDrive has eight options:

Option --ls or -s

Runs ls after warping to a directory.

 wd --help

Option --help or -h

Prints a small help message:

 wd --help

Output:

WarpDrive - Warp across directories
Usage: wd [<option>] [<pattern> ...]
Options:
   --ls, -s                   Run ls after warping to a directory
   --add, -a <path> ...       Add paths to be tracked. Paths are automatically added when visited
   --remove, -r <path> ...    Remove paths so they are no longer tracked
   --list, -l                 List tracked paths and their points, sorted by most
   --update                   Update WarpDrive to the latest commit
   --help, -h                 Print this help message
   --version, -v              Print the version of WarpDrive you have   --check, -c                Checks if a newer version is available
Examples:
   wd
   wd dir-in-pwd
   wd dir-that-was-visited-before
   wd grand-parent-dir parent-dir child-dir
   wd parent-dir grand-parent-dir child-dir
   wd a-part-of-the-name-of-some-dir
   wd /absolute/path/to/somewhere
   wd -s run-ls-after-warping
   wd --add dir-to-add
   wd --remove dir-to-remove
Note:
   To go to the home directory don't specify any arguments, i.e. use just `wd` (like cd)
   When specifying multiple patterns, order doesn't matter except for the last pattern given
      i.e. WarpDrive will always take you to a directory whose name matches the last pattern
   If <pattern> is specified after an option, <pattern> will be ignored unless the option is -s
   No options can be combined (you can't use any two options at the same time)
   Any output seen is on stderr

Refer to https://github.com/quackduck/WarpDrive for more information

Option --update

Updates WarpDrive to the latest commit. It is recommended to update with wd --update to ensure you have the latest WarpDrive.

wd --update

Option -a or --add

Adds paths. Paths are automatically added when you visit them.

wd --add /Users /usr/local/bin

Option -r or --remove

Removes paths. This does not "decrement" frequency. It completely deletes a path, so it is no longer tracked (Unless, of course, you visit it again).

wd --remove /Users /usr/local/bin

Option -l or --list

Shows tracked directories and their points, sorted by most.

wd --list

Sample output:

Points   Directory
150.0    /Users/ishan/Desktop/GitHub/WarpDrive
36.0     /Users/ishan/Desktop/tests/foo
6.0      /Users/ishan/.config/fish
5.0      /Users/ishan/.config
3.0      /Users/ishan/.config/fish/functions
1.0      /usr/libexec
1.0      /Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home
1.0      /Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/bin
1.0      /
1.0      /Users/ishan/Downloads
1.0      /Users/ishan
1.0      /Users/ishan/.config/fish/conf.d
0.5      /Users/ishan/Desktop
0.5      /Users/ishan/Desktop/tests

Option -c or --check Checks for newer WarpDrive versions

wd --check

Example output:

Newer version: WarpDrive 1.0.1 is available
You currently have: WarpDrive 1.0.0
Run `wd --update` to update to the latest version

Option -v or --version Prints the version of WarpDrive you have

wd --version

Example output:

WarpDrive 1.0.0

Even though most of these "options" would be better implemented as standalone actions, they are implemented as regular options because they have the advantage of not being like filenames

Different Arguments

WarpDrive recognizes seperate arguments as matching different directories in a path. They do not need to be in order.

Both

wd grandParentDir parentDir childDir

or

wd parent grand child

will have the same result.

Note! WarpDrive will always take you to a directory matching the last pattern. For more info on what this means, check the second Caveat.

Installing or Uninstalling

fish is currently supported.

You need to have java installed for WarpDrive to work. Use brew cask install java if you have Homebrew installed

Fish Install or Uninstall

WarpDrive can be installed by running this command:

curl -sS https://raw.githubusercontent.com/quackduck/WarpDrive/master/fish/install.fish | fish

and uninstalled by running this command:

curl -sS https://raw.githubusercontent.com/quackduck/WarpDrive/master/fish/uninstall.fish | fish

Compatibility

The datafile format is the same as rupa/z, jethrokuan/z, zsh-z and z.lua

Known Issues

WarpDrive is a bit slow, compared to native shell scripts, taking ~150ms on average (tested using Hyperfine) for most commands (This could be different for you. Do inform me about WarpDrive's performance or leave a review at igoel.mail@gmail.com) This is because the JVM takes a lot of time to start up. The application itself takes 30ms.

Caveats

WarpDrive stores data at ~/.WarpDrive/WarpDriveData.txt.

WarpDrive will always take you to a directory that matches the last pattern given. In other words, if the datafile contains two directories: /foo/bar and /bar/foo and you use the command wd f it will take you to /bar/foo.

WarpDrive is not case sensitive. wd Bar is the same as wd bar.

Just wd takes you to the home directory.

No options except -s can be grouped together. wd -hl --add / won't work but wd -s / will

If any options except -s are specified, you stay in the same directory even if you specified a directory. wd -l someDir won't work

Suggestions are welcome, file those or issues here.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


RiceBoi

⚠️ 🤔 🐛

Aaryan Porwal

⚠️ 🤔 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!