1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-15 02:10:08 +00:00
ohmyzsh/plugins/wd/README.md

241 lines
5.3 KiB
Markdown
Raw Normal View History

2020-06-03 16:35:51 +00:00
# wd
2014-09-07 19:56:34 +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.
2014-09-07 19:56:34 +00:00
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
2015-01-25 23:13:39 +00:00
*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.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## Setup
2014-09-07 19:56:34 +00:00
### oh-my-zsh
2020-06-03 16:35:51 +00:00
`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
2014-09-07 19:56:34 +00:00
Just add the plugin in your `~/.zshrc` file:
2020-06-03 16:35:51 +00:00
```zsh
plugins=(... wd)
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
### [Antigen](https://github.com/zsh-users/antigen)
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
In your `.zshrc`:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
antigen bundle mfaerevaag/wd
```
### [Antibody](https://github.com/getantibody/antibody)
In your `.zshrc`:
```zsh
antibody bundle mfaerevaag/wd
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
### [zplug](https://github.com/zplug/zplug)
2020-06-03 16:35:51 +00:00
```zsh
zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
```
### Automatic
Run either in terminal:
2020-06-03 16:35:51 +00:00
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
or
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
### Manual
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Clone this repo to your liking
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Add `wd` function to `.zshrc` (or `.profile` etc.):
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd() {
. ~/path/to/cloned/repo/wd/wd.sh
}
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Install manpage. From `wd`'s base directory (requires root permissions):
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
cp wd.1 /usr/share/man/man1/wd.1
chmod 644 /usr/share/man/man1/wd.1
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
**Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## Completion
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00: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`:
```zsh
fpath=(~/path/to/wd $fpath)
```
2014-09-07 19:56:34 +00:00
Also, you may have to force a rebuild of `zcompdump` by running:
2020-06-03 16:35:51 +00:00
```zsh
rm -f ~/.zcompdump; compinit
```
2020-06-03 16:35:51 +00:00
## Usage
2020-06-03 16:35:51 +00:00
* Add warp point to current working directory:
2020-06-03 16:35:51 +00:00
```zsh
wd add foo
```
2020-06-03 16:35:51 +00:00
If a warp point with the same name exists, use `wd add! foo` to overwrite it.
2020-06-03 16:35:51 +00: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.
2020-06-03 16:35:51 +00:00
You can omit point name to automatically use the current directory's name instead.
2020-06-03 16:35:51 +00:00
* From any directory, warp to `foo` with:
2020-06-03 16:35:51 +00:00
```zsh
wd foo
```
2020-06-03 16:35:51 +00:00
* You can also warp to a directory within foo, with autocompletion:
2020-06-03 16:35:51 +00:00
```zsh
wd foo some/inner/path
```
2020-06-03 16:35:51 +00:00
* You can warp back to previous directory and higher, with this dot syntax:
2020-06-03 16:35:51 +00:00
```zsh
wd ..
wd ...
```
2020-06-03 16:35:51 +00:00
This is a wrapper for the zsh's `dirs` function.
_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh))._
2020-06-03 16:35:51 +00:00
* Remove warp point:
2020-06-03 16:35:51 +00:00
```zsh
wd rm foo
```
2020-06-03 16:35:51 +00:00
You can omit point name to use the current directory's name instead.
2020-06-03 16:35:51 +00:00
* List all warp points (stored in `~/.warprc`):
2020-06-03 16:35:51 +00:00
```zsh
wd list
```
2015-01-25 23:13:39 +00:00
2020-06-03 16:35:51 +00:00
* List files in given warp point:
2015-01-25 23:13:39 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd ls foo
```
2015-01-25 23:13:39 +00:00
2020-06-03 16:35:51 +00:00
* Show path of given warp point:
2015-01-25 23:13:39 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd path foo
```
2020-06-03 16:35:51 +00:00
* List warp points to current directory, or optionally, path to given warp point:
2020-06-03 16:35:51 +00:00
```zsh
wd show
```
2020-06-03 16:35:51 +00:00
* Remove warp points to non-existent directories.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd clean
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
Use `wd clean!` to not be prompted with confirmation (force).
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Print usage info:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd help
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
The usage will be printed also if you call `wd` with no command
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Print the running version of `wd`:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd --version
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd --config ./file <command>
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd --debug <command>
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
* Silence all output:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
wd --quiet <command>
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## Configuration
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
You can configure `wd` with the following environment variables:
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
### `WD_CONFIG`
Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## Testing
`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 they should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
```zsh
cd ./test
./tests.sh
```
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## License
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
The project is licensed under the [MIT license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
## Contributing
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +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.
2014-09-07 19:56:34 +00:00
2020-06-03 16:35:51 +00:00
----
2014-09-07 19:56:34 +00:00
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
2014-09-07 19:56:34 +00:00
Hope you enjoy!