2020-06-04 00:35:51 +08:00
# wd
2014-09-08 03:56:34 +08:00
2022-11-07 03:52:53 +08:00
[![Build Status ](https://github.com/mfaerevaag/wd/actions/workflows/test.yml/badge.svg )](https://github.com/mfaerevaag/wd/actions)
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
`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.
2014-09-08 03:56:34 +08:00
2022-11-07 03:52:53 +08:00
![Demo ](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif )
2015-01-26 07:13:39 +08:00
2020-06-04 00:35:51 +08:00
## Setup
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
`wd` comes bundled with oh-my-zsh!
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
Just add the plugin in your `.zshrc` file:
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
plugins=(... wd)
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
### [Antigen](https://github.com/zsh-users/antigen)
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
In your `.zshrc` :
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
antigen bundle mfaerevaag/wd
```
### [Antibody](https://github.com/getantibody/antibody)
In your `.zshrc` :
```zsh
antibody bundle mfaerevaag/wd
```
2014-09-08 03:56:34 +08:00
2022-11-07 03:52:53 +08:00
### [Fig](https://fig.io)
Install `wd` here: [![Fig plugin store ](https://fig.io/badges/install-with-fig.svg )](https://fig.io/plugins/other/wd_mfaerevaag)
2020-06-04 00:35:51 +08:00
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
1. Install from the AUR
2020-06-04 00:35:51 +08:00
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
2. Then add to your `.zshrc` :
```zsh
wd() {
. /usr/share/wd/wd.sh
}
```
2024-05-12 18:42:59 +08:00
### [Home Manager](https://github.com/nix-community/home-manager)
Add the following to your `home.nix` then run `home-manager switch` :
```nix
programs.zsh.plugins = [
{
name = "wd";
src = pkgs.fetchFromGitHub {
owner = "mfaerevaag";
repo = "wd";
rev = "v0.5.2";
sha256 = "sha256-4yJ1qhqhNULbQmt6Z9G22gURfDLe30uV1ascbzqgdhg=";
};
}
];
```
2020-06-04 00:35:51 +08:00
### [zplug](https://github.com/zplug/zplug)
2017-11-01 21:03:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
```
### Automatic
2020-09-09 20:24:43 +08:00
_Note: automatic install does not provide the manpage. It is also poor security practice to run remote code without first reviewing it, so you ought to look [here ](https://github.com/mfaerevaag/wd/blob/master/install.sh )_
Run either command in your terminal:
2017-11-01 21:03:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
or
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
### Manual
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
1. Clone this repository on your local machine in a sensible location (if you know what you're doing of course all of this is up to you):
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
2. Add `wd` function to `.zshrc` (or `.profile` etc.):
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd() {
. ~/.local/wd/wd.sh
}
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
3. Install manpage (optional):
2014-09-08 03:56:34 +08:00
2024-09-15 14:16:50 +08:00
Move manpage into an appropriate directory, then trigger `mandb` to discover it
2020-09-09 20:24:43 +08:00
```zsh
2024-09-15 14:16:50 +08:00
sudo install -m 644 ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
sudo mandb /usr/share/man/man1
2020-09-09 20:24:43 +08:00
```
**Note:** when pulling and updating `wd` , you'll need to repeat step 3 should the manpage change
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
## Completion
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
If you're NOT using [oh-my-zsh ](https://github.com/robbyrussell/oh-my-zsh ) 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` :
2020-06-04 00:35:51 +08:00
```zsh
fpath=(~/path/to/wd $fpath)
```
2014-09-08 03:56:34 +08:00
Also, you may have to force a rebuild of `zcompdump` by running:
2020-06-04 00:35:51 +08:00
```zsh
rm -f ~/.zcompdump; compinit
```
2013-11-26 07:46:13 +08:00
2024-05-12 18:42:59 +08:00
## Browse
2024-09-15 14:16:50 +08:00
`wd` comes with an `fzf` -powered browse feature to fuzzy search through all your warp points. It's available through the `wd browse` command. For quick access you can set up an alias or keybind in your `.zshrc` :
2024-05-12 18:42:59 +08:00
```zsh
2024-09-15 14:16:50 +08:00
# ctrl-b to open the fzf browser
bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget
2024-05-12 18:42:59 +08:00
```
2020-06-04 00:35:51 +08:00
## Usage
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* Add warp point to current working directory:
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd add foo
```
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
If a warp point with the same name exists, use `wd add foo --force` to overwrite it.
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
**Note:** a warp point cannot contain colons, or 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.
2013-11-26 07:46:13 +08:00
2024-05-22 02:48:54 +08:00
* Add warp point to any directory with default name:
```zsh
wd addcd /foo/ bar
```
* Add warp point to any directory with a custom name:
```zsh
wd addcd /foo/
```
2020-09-09 20:24:43 +08:00
You can omit point name to automatically use the current directory's name instead.
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* From any directory, warp to `foo` with:
2017-11-01 21:03:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd foo
```
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
* You can also warp to a directory within `foo` , with autocompletion:
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd foo some/inner/path
```
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* You can warp back to previous directory and higher, with this dot syntax:
2014-07-15 23:42:30 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd ..
wd ...
```
2013-11-26 07:46:13 +08:00
2024-05-12 18:42:59 +08:00
This is a wrapper for the zsh's `dirs` function.
2020-09-09 20:24:43 +08:00
_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh ](https://github.com/ohmyzsh/ohmyzsh )._
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* Remove warp point:
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd rm foo
```
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
You can omit point name to use the current directory's name instead.
2017-11-01 21:03:34 +08:00
2020-09-09 20:24:43 +08:00
* List all warp points (stored in `~/.warprc` by default):
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd list
```
2015-01-26 07:13:39 +08:00
2020-06-04 00:35:51 +08:00
* List files in given warp point:
2015-01-26 07:13:39 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd ls foo
```
2015-01-26 07:13:39 +08:00
2020-06-04 00:35:51 +08:00
* Show path of given warp point:
2015-01-26 07:13:39 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd path foo
```
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* List warp points to current directory, or optionally, path to given warp point:
2013-11-26 07:46:13 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd show
```
2013-11-26 07:46:13 +08:00
2020-06-04 00:35:51 +08:00
* Remove warp points to non-existent directories.
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd clean
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
Use `wd clean --force` to not be prompted with confirmation.
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
* Print usage info:
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd help
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
The usage will be printed also if you call `wd` with no command
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
* Print the running version of `wd` :
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd --version
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
* Specifically set the config file (default being `~/.warprc` ), which is useful for testing:
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd --config ./file < command >
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
* Silence all output:
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
```zsh
wd --quiet < command >
```
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
## Configuration
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
You can configure `wd` with the following environment variables:
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
### `WD_CONFIG`
Defines the path where warp points get stored. Defaults to `$HOME/.warprc` .
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
## Testing
2020-09-09 20:24:43 +08:00
`wd` comes with a small test suite, run with [shunit2 ](https://github.com/kward/shunit2 ). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
2020-06-04 00:35:51 +08:00
To run, simply `cd` into the `test` directory and run the `tests.sh` .
2014-09-08 03:56:34 +08:00
2020-06-04 00:35:51 +08:00
```zsh
cd ./test
./tests.sh
```
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
## Maintainers
Following @mfaerevaag stepping away from active maintainership of this repository, the following users now are also maintainers of the repo:
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
* @alpha -tango-kilo
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
* @MattLewin
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
2014-09-08 03:56:34 +08:00
2020-09-09 20:24:43 +08:00
---
2014-09-08 03:56:34 +08:00
2017-11-01 21:03:34 +08:00
Credit to [altschuler ](https://github.com/altschuler ) for an awesome idea.
2014-09-08 03:56:34 +08:00
Hope you enjoy!