2020-06-11 14:59:30 +00:00
wd
==
2019-01-12 15:47:23 +00:00
[![Build Status ](https://travis-ci.org/mfaerevaag/wd.png?branch=master )](https://travis-ci.org/mfaerevaag/wd)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd` . Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
![tty.gif ](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif )
*NEWS*: If you are not using zsh, check out the c-port, [wd-c ](https://github.com/mfaerevaag/wd-c ), which works with all shells using wrapper functions.
2020-06-11 14:59:30 +00:00
### Setup
2019-01-12 15:47:23 +00:00
### oh-my-zsh
2020-06-11 14:59:30 +00:00
`wd` comes bundled with [oh-my-zshell ](https://github.com/ohmyzsh/ohmyzsh )!
2019-01-12 15:47:23 +00:00
Just add the plugin in your `~/.zshrc` file:
2020-06-11 14:59:30 +00:00
plugins=(... wd)
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
#### Automatic
2020-06-11 14:41:32 +00:00
Run either in terminal:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
##### Arch ([AUR](https://aur.archlinux.org/))
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
# yaourt -S zsh-plugin-wd-git
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
#### Manual
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Clone this repo to your liking
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Add `wd` function to `.zshrc` (or `.profile` etc.):
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
wd() {
. ~/path/to/cloned/repo/wd/wd.sh
}
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Install manpage. From `wd` 's base directory (requires root permissions):
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
# cp wd.1 /usr/share/man/man1/wd.1
# chmod 644 /usr/share/man/man1/wd.1
2020-06-11 14:41:32 +00:00
2020-06-11 14:59:30 +00:00
Note, when pulling and updating `wd` , you'll need to do this again in case of changes to the manpage.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
#### Completion
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
If you're NOT using [oh-my-zsh ](https://github.com/ohmyzsh/ohmyzsh ) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath` . E.g. in your `~/.zshrc` :
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
fpath=(~/path/to/wd $fpath)
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
Also, you may have to force a rebuild of `zcompdump` by running:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ rm -f ~/.zcompdump; compinit
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
### Usage
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Add warp point to current working directory:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd add foo
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
If a warp point with the same name exists, use `add!` to overwrite it.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
You can omit point name to use the current directory's name instead.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* From an other directory (not necessarily), warp to `foo` with:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd foo
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* You can warp back to previous directory, and so on, with this dot syntax:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd ..
$ wd ...
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
This is a wrapper for the zsh `dirs` function.
(You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell ](https://github.com/ohmyzsh/ohmyzsh )).
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Remove warp point test point:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd rm foo
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
You can omit point name to use the current directory's name instead.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* List all warp points (stored in `~/.warprc` ):
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd list
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* List files in given warp point:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd ls foo
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Show path of given warp point:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd path foo
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* List warp points to current directory, or optionally, path to given warp point:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd show
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Remove warp points to non-existent directories.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd clean
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
Use `clean!` to not be prompted with confirmation (force).
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Print usage with no opts or the `help` argument:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd help
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Print the running version of `wd` :
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd --version
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Specifically set the config file (default `~/.warprc` ), which is useful when testing:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd --config ./file < action >
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Force `exit` with return code after running. This is not default, as it will *exit your terminal* , though required when testing/debugging.
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd --debug < action >
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
* Silence all output:
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ wd --quiet < action >
2020-06-11 14:41:32 +00:00
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
### Testing
2020-06-11 14:41:32 +00:00
2020-06-11 14:59:30 +00:00
`wd` comes with a small test suite, run with [shunit2 ](https://code.google.com/p/shunit2/ ). This can be used to confirm that things are working as it should on your setup, or to demonstrate an issue.
2020-06-11 14:41:32 +00:00
To run, simply `cd` into the `test` directory and run the `tests.sh` .
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
$ ./tests.sh
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
### License
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
The project is licensed under the [MIT-license ](https://github.com/mfaerevaag/wd/blob/master/LICENSE ).
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
### Finally
2019-01-12 15:47:23 +00:00
2020-06-11 14:59:30 +00:00
If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh` . For an explanation on how to run the tests, read the section "Testing" in this README.
2019-01-12 15:47:23 +00:00
Credit to [altschuler ](https://github.com/altschuler ) for an awesome idea.
Hope you enjoy!