README.md 5.39 KB
Newer Older
1
# wd
2
3
4

[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)

5
6
7
`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.
8

9
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
Markus Faerevaag's avatar
Markus Faerevaag committed
10

11
## Setup
12

13
### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
14

15
`wd` comes bundled with oh-my-zsh!
16

17
Just add the plugin in your `.zshrc` file:
18

19
20
21
```zsh
plugins=(... wd)
```
22

23
### [Antigen](https://github.com/zsh-users/antigen)
24

25
In your `.zshrc`:
26

27
28
29
30
31
32
33
34
35
36
37
```zsh
antigen bundle mfaerevaag/wd
```

### [Antibody](https://github.com/getantibody/antibody)

In your `.zshrc`:

```zsh
antibody bundle mfaerevaag/wd
```
38

39
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
40

41
42
1. Install from the AUR

43
44
45
46
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
47

48
49
50
51
52
53
54
55
2. Then add to your `.zshrc`:

```zsh
wd() {
    . /usr/share/wd/wd.sh
}
```

56
### [zplug](https://github.com/zplug/zplug)
57

58
59
60
61
62
63
```zsh
zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
```

### Automatic

64
65
66
_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:
67

68
69
70
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
```
71

72
or
73

74
75
76
```zsh
wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh
```
77

78
### Manual
79

80
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):
81

82
83
84
```zsh
git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
```
85

86
2. Add `wd` function to `.zshrc` (or `.profile` etc.):
87

88
89
90
91
92
```zsh
wd() {
    . ~/.local/wd/wd.sh
}
```
93

94
3. Install manpage (optional):
95

96
97
98
99
100
101
```zsh
sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
sudo chmod 644 /usr/share/man/man1/wd.1
```

**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
102

103
## Completion
104

105
106
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`:
107
108
109
110

```zsh
fpath=(~/path/to/wd $fpath)
```
111
112
113

Also, you may have to force a rebuild of `zcompdump` by running:

114
115
116
```zsh
rm -f ~/.zcompdump; compinit
```
117

118
## Usage
119

120
* Add warp point to current working directory:
121

122
123
124
```zsh
wd add foo
```
125

126
If a warp point with the same name exists, use `wd add foo --force` to overwrite it.
127

128
129
**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.
130

131
You can omit point name to automatically use the current directory's name instead.
132

133
* From any directory, warp to `foo` with:
134

135
136
137
```zsh
wd foo
```
138

139
* You can also warp to a directory within `foo`, with autocompletion:
140

141
142
143
```zsh
wd foo some/inner/path
```
144

145
* You can warp back to previous directory and higher, with this dot syntax:
146

147
148
149
150
```zsh
wd ..
wd ...
```
151

152
153
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)._
154

155
* Remove warp point:
156

157
158
159
```zsh
wd rm foo
```
160

161
You can omit point name to use the current directory's name instead.
162

163
* List all warp points (stored in `~/.warprc` by default):
164

165
166
167
```zsh
wd list
```
Markus Faerevaag's avatar
Markus Faerevaag committed
168

169
* List files in given warp point:
Markus Faerevaag's avatar
Markus Faerevaag committed
170

171
172
173
```zsh
wd ls foo
```
Markus Faerevaag's avatar
Markus Faerevaag committed
174

175
* Show path of given warp point:
Markus Faerevaag's avatar
Markus Faerevaag committed
176

177
178
179
```zsh
wd path foo
```
180

181
* List warp points to current directory, or optionally, path to given warp point:
182

183
184
185
```zsh
wd show
```
186

187
* Remove warp points to non-existent directories.
188

189
190
191
```zsh
wd clean
```
192

193
Use `wd clean --force` to not be prompted with confirmation.
194

195
* Print usage info:
196

197
198
199
```zsh
wd help
```
200

201
The usage will be printed also if you call `wd` with no command
202

203
* Print the running version of `wd`:
204

205
206
207
```zsh
wd --version
```
208

209
* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
210

211
212
213
```zsh
wd --config ./file <command>
```
214

215
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
216

217
218
219
```zsh
wd --debug <command>
```
220

221
* Silence all output:
222

223
224
225
```zsh
wd --quiet <command>
```
226

227
## Configuration
228

229
You can configure `wd` with the following environment variables:
230

231
232
233
### `WD_CONFIG`

Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
234

235
236
## Testing

237
`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.
238
239

To run, simply `cd` into the `test` directory and run the `tests.sh`.
240

241
242
243
244
```zsh
cd ./test
./tests.sh
```
245

246
247
248
## Maintainers

Following @mfaerevaag stepping away from active maintainership of this repository, the following users now are also maintainers of the repo:
249

250
* @alpha-tango-kilo
251

252
* @MattLewin
253

254
Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
255

256
---
257

258
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
259
260

Hope you enjoy!