README.md 4.48 KB
Newer Older
1
2
3
4
5
wd
==

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

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

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

10
*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.
11
12
13
14
15

### Setup

### oh-my-zsh

16
`wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
17
18
19
20
21
22
23
24
25
26
27
28
29
30

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

    plugins=(... wd)


#### Automatic

Run either in terminal:

 * `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`

 * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`

31
32
33
34
##### Arch ([AUR](https://aur.archlinux.org/))

    # yaourt -S zsh-plugin-wd-git

35
36
37
38
39
40
41
42

#### Manual

 * Clone this repo to your liking

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

        wd() {
Markus Faerevaag's avatar
Markus Faerevaag committed
43
            . ~/path/to/cloned/repo/wd/wd.sh
44
45
46
47
48
49
50
51
52
53
54
55
        }

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

        # cp wd.1 /usr/share/man/man1/wd.1
        # chmod 644 /usr/share/man/man1/wd.1

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


#### Completion

56
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`:
57
58
59
60
61
62

    fpath=(~/path/to/wd $fpath)

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

    $ rm -f ~/.zcompdump; compinit
63
64
65
66
67
68
69



### Usage

 * Add warp point to current working directory:

70
        $ wd add foo
71
72
73

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

74
75
76
    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.

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

78
 * From an other directory (not necessarily), warp to `foo` with:
79

80
        $ wd foo
81

82
83
84
85
 * You can warp back to previous directory, and so on, with this dot syntax:

        $ wd ..
        $ wd ...
86
87

    This is a wrapper for the zsh `dirs` function.
88
    (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)).
89
90
91

 * Remove warp point test point:

92
        $ wd rm foo
93

94
95
    You can omit point name to use the current directory's name instead.

96
 * List all warp points (stored in `~/.warprc`):
97

Markus Faerevaag's avatar
Markus Faerevaag committed
98
99
100
101
102
103
104
105
106
        $ wd list

 * List files in given warp point:

        $ wd ls foo

 * Show path of given warp point:

        $ wd path foo
107

108
 * List warp points to current directory, or optionally, path to given warp point:
109

110
        $ wd show
111

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 * Remove warp points to non-existent directories.

        $ wd clean

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

 * Print usage with no opts or the `help` argument:

        $ wd help

 * Print the running version of `wd`:

        $ wd --version

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

        $ wd --config ./file <action>

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

        $ wd --debug <action>

 * Silence all output:

        $ wd --quiet <action>


### 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 it should on your setup, or to demonstrate an issue.

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

    $ ./tests.sh


### License

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


### Finally

155
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.
156

157
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
158
159

Hope you enjoy!