README.md 5.32 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
`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.
6

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

9
*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.
10

11
## Setup
12
13
14

### oh-my-zsh

15
`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
16
17
18

Just add the plugin in your `~/.zshrc` file:

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
43
44
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
45

46
### [zplug](https://github.com/zplug/zplug)
47

48
49
50
51
52
53
54
```zsh
zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
```

### Automatic

Run either in terminal:
55

56
57
58
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
```
59

60
or
61

62
63
64
```zsh
wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh
```
65

66
### Manual
67

68
* Clone this repo to your liking
69

70
* Add `wd` function to `.zshrc` (or `.profile` etc.):
71

72
73
74
75
76
  ```zsh
  wd() {
      . ~/path/to/cloned/repo/wd/wd.sh
  }
  ```
77

78
* Install manpage. From `wd`'s base directory (requires root permissions):
79

80
81
82
83
  ```zsh
  cp wd.1 /usr/share/man/man1/wd.1
  chmod 644 /usr/share/man/man1/wd.1
  ```
84

85
  **Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
86

87
## Completion
88

89
90
91
92
93
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)
```
94
95
96

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

97
98
99
```zsh
rm -f ~/.zcompdump; compinit
```
100

101
## Usage
102

103
* Add warp point to current working directory:
104

105
106
107
  ```zsh
  wd add foo
  ```
108

109
  If a warp point with the same name exists, use `wd add! foo` to overwrite it.
110

111
  **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.
112

113
  You can omit point name to automatically use the current directory's name instead.
114

115
* From any directory, warp to `foo` with:
116

117
118
119
  ```zsh
  wd foo
  ```
120

121
* You can also warp to a directory within foo, with autocompletion:
122

123
124
125
  ```zsh
  wd foo some/inner/path
  ```
126

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

129
130
131
132
  ```zsh
  wd ..
  wd ...
  ```
133

134
135
  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))._
136

137
* Remove warp point:
138

139
140
141
  ```zsh
  wd rm foo
  ```
142

143
  You can omit point name to use the current directory's name instead.
144

145
* List all warp points (stored in `~/.warprc`):
146

147
148
149
  ```zsh
  wd list
  ```
Markus Faerevaag's avatar
Markus Faerevaag committed
150

151
* List files in given warp point:
Markus Faerevaag's avatar
Markus Faerevaag committed
152

153
154
155
  ```zsh
  wd ls foo
  ```
Markus Faerevaag's avatar
Markus Faerevaag committed
156

157
* Show path of given warp point:
Markus Faerevaag's avatar
Markus Faerevaag committed
158

159
160
161
  ```zsh
  wd path foo
  ```
162

163
* List warp points to current directory, or optionally, path to given warp point:
164

165
166
167
  ```zsh
  wd show
  ```
168

169
* Remove warp points to non-existent directories.
170

171
172
173
  ```zsh
  wd clean
  ```
174

175
  Use `wd clean!` to not be prompted with confirmation (force).
176

177
* Print usage info:
178

179
180
181
  ```zsh
  wd help
  ```
182

183
  The usage will be printed also if you call `wd` with no command
184

185
* Print the running version of `wd`:
186

187
188
189
  ```zsh
  wd --version
  ```
190

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

193
194
195
  ```zsh
  wd --config ./file <command>
  ```
196

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

199
200
201
  ```zsh
  wd --debug <command>
  ```
202

203
* Silence all output:
204

205
206
207
  ```zsh
  wd --quiet <command>
  ```
208

209
## Configuration
210

211
You can configure `wd` with the following environment variables:
212

213
214
215
### `WD_CONFIG`

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

217
218
219
220
221
## 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`.
222

223
224
225
226
```zsh
cd ./test
./tests.sh
```
227

228
## License
229

230
The project is licensed under the [MIT license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
231

232
## Contributing
233

234
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.
235

236
----
237

238
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
239
240

Hope you enjoy!