diff options
| author | Markus Færevaag <mf@bitblueprint.com> | 2013-11-26 00:46:13 +0100 | 
|---|---|---|
| committer | Markus Færevaag <mf@bitblueprint.com> | 2013-11-26 00:46:13 +0100 | 
| commit | b4ffe5cf0a9e0a076fc1c52f6a46eefe05ad5627 (patch) | |
| tree | eb9100bc62238b24019aae30a8711c4cf979a799 /plugins/wd | |
| parent | 240b25daaaee81ccdb9e6e2016667a60f5241f83 (diff) | |
| download | zsh-b4ffe5cf0a9e0a076fc1c52f6a46eefe05ad5627.tar.gz zsh-b4ffe5cf0a9e0a076fc1c52f6a46eefe05ad5627.tar.bz2 zsh-b4ffe5cf0a9e0a076fc1c52f6a46eefe05ad5627.zip | |
wd.plugin: Added checks, readme and completion
Diffstat (limited to 'plugins/wd')
| -rw-r--r-- | plugins/wd/README.md | 38 | ||||
| -rw-r--r-- | plugins/wd/_wd.sh | 48 | 
2 files changed, 86 insertions, 0 deletions
| diff --git a/plugins/wd/README.md b/plugins/wd/README.md new file mode 100644 index 000000000..f9f4e7ac1 --- /dev/null +++ b/plugins/wd/README.md @@ -0,0 +1,38 @@ +## wd + +**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag) + +`wd` (warp directory) lets you jump to custom directories in zsh, without using cd. Why? Because cd seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd) + +### Usage + + * Add warp point to current working directory: + +        wd add test + +    If a warp point with the same name exists, use `add!` to overwrite it. + + * From an other directory, warp to test with: + +        wd test + + * You can warp back to previous directory, and so on, with the puncticulation syntax: + +        wd .. +        wd ... + +    This is a wrapper for the zsh `dirs` function. + + * Remove warp point test point: + +        wd rm test + + * List warp points to current directory (stored in `~/.warprc`): + +        wd show + + * List all warp points (stored in `~/.warprc`): + +        wd ls + + * Print usage with no opts or the `help` argument. diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh new file mode 100644 index 000000000..950564435 --- /dev/null +++ b/plugins/wd/_wd.sh @@ -0,0 +1,48 @@ +#compdef wd.sh + +zstyle ":completion:*:descriptions" format "%B%d%b" + +CONFIG=$HOME/.warprc + +local -a main_commands +main_commands=( +    add:'Adds the current working directory to your warp points' +    #add'\!':'Overwrites existing warp point' # TODO: Fix +    rm:'Removes the given warp point' +    ls:'Outputs all stored warp points' +    show:'Outputs warp points to current directory' +) + +local -a points +while read line +do +    points+=$(awk "{ gsub(/\/Users\/$USER|\/home\/$USER/,\"~\"); print }" <<< $line) +done < $CONFIG + +_wd() +{ +    # init variables +    local curcontext="$curcontext" state line +    typeset -A opt_args + +    # init state +    _arguments \ +        '1: :->command' \ +        '2: :->argument' + +    case $state in +        command) +            compadd "$@" add rm ls show +            _describe -t warp-points 'Warp points:' points && ret=0 +            ;; +        argument) +            case $words[2] in +                rm|add!) +                    _describe -t warp-points 'warp points' points && ret=0 +                    ;; +                *) +            esac +    esac +} + +_wd "$@" | 
