2102d10896fe14e912ed6ed8075bb0ddd3a5bc6a
- Author
- Markus Færevaag <m@frv.ag>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/wd/README.md b/plugins/wd/README.md
2index ed149eb3ed3e5e8414b6edea3d7cbbdcf1c8b467..b1deeffd512add4ce1c1024eb6ad4fdf56a8e9d5 100644
3--- a/plugins/wd/README.md
4+++ b/plugins/wd/README.md
5@@ -3,16 +3,17 @@ wd
6
7 [](https://travis-ci.org/mfaerevaag/wd)
8
9-`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.
10+`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.
11
12-*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem.
13+
14
15+*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.
16
17 ### Setup
18
19 ### oh-my-zsh
20
21-`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
22+`wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
23
24 Just add the plugin in your `~/.zshrc` file:
25
26@@ -27,6 +28,10 @@ Run either in terminal:
27
28 * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
29
30+##### Arch ([AUR](https://aur.archlinux.org/))
31+
32+ # yaourt -S zsh-plugin-wd-git
33+
34
35 #### Manual
36
37@@ -48,7 +53,7 @@ Run either in terminal:
38
39 #### Completion
40
41diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
42index b67f4a1e25599983bb592ca88545d6b626958f82..65fa1dddeff26774ea952d0a5b759bc20c2108f7 100644
43--- a/plugins/wd/_wd.sh
44+++ b/plugins/wd/_wd.sh
45@@ -16,6 +16,19 @@ function _wd() {
46
47 warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
48
49+ typeset -A points
50+ while read -r line
51+ do
52+ arr=(${(s,:,)line})
53+ name=${arr[1]}
54+ path=${arr[2]}
55+
56+ # replace ~ from path to fix completion (#17)
57+ path=${path/#\~/$HOME}
58+
59+ points[$name]=$path
60+ done < $CONFIG
61+
62 commands=(
63 'add:Adds the current working directory to your warp points'
64 'add!:Overwrites existing warp point'
65@@ -34,13 +47,15 @@ function _wd() {
66 '1: :->first_arg' \
67 '2: :->second_arg' && ret=0
68
69+ local target=$words[2]
70+
71 case $state in
72 first_arg)
73 _describe -t warp_points "Warp points" warp_points && ret=0
74 _describe -t commands "Commands" commands && ret=0
75 ;;
76 second_arg)
77- case $words[2] in
78+ case $target in
79 add\!|rm)
80 _describe -t points "Warp points" warp_points && ret=0
81 ;;
82@@ -56,6 +71,10 @@ function _wd() {
83 path)
84 _describe -t points "Warp points" warp_points && ret=0
85 ;;
86+ *)
87+ # complete sub directories from the warp point
88+ _path_files -W "(${points[$target]})" -/ && ret=0
89+ ;;
90 esac
91 ;;
92 esac
93diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
94index cf54713bd83d3237101a5ec8575d488caf29fcb6..c330dd35875a46c1bc535b91e76496fe3077dde3 100755
95--- a/plugins/wd/wd.sh
96+++ b/plugins/wd/wd.sh
97@@ -8,7 +8,7 @@
98 # @github.com/mfaerevaag/wd
99
100 # version
101-readonly WD_VERSION=0.4.2
102+readonly WD_VERSION=0.4.4
103
104 # colors
105 readonly WD_BLUE="\033[96m"
106@@ -72,25 +72,28 @@ wd_print_msg()
107 wd_print_usage()
108 {
109 cat <<- EOF
110-Usage: wd [command] <point>
111+Usage: wd [command] [point]
112
113 Commands:
114- add <point> Adds the current working directory to your warp points
115- add! <point> Overwrites existing warp point
116- rm <point> Removes the given warp point
117- show Print warp points to current directory
118- show <point> Print path to given warp point
119- list Print all stored warp points
120-ls <point> Show files from given warp point
121-path <point> Show the path to given warp point
122- clean! Remove points warping to nonexistent directories
123-
124- -v | --version Print version
125- -d | --debug Exit after execution with exit codes (for testing)
126- -c | --config Specify config file (default ~/.warprc)
127- -q | --quiet Suppress all output
128-
129- help Show this extremely helpful text
130+ add <point> Adds the current working directory to your warp points
131+ add Adds the current working directory to your warp points with current directory's name
132+ add! <point> Overwrites existing warp point
133+ add! Overwrites existing warp point with current directory's name
134+ rm <point> Removes the given warp point
135+ rm Removes the given warp point with current directory's name
136+ show <point> Print path to given warp point
137+ show Print warp points to current directory
138+ list Print all stored warp points
139+ ls <point> Show files from given warp point (ls)
140+ path <point> Show the path to given warp point (pwd)
141+ clean! Remove points warping to nonexistent directories
142+
143+ -v | --version Print version
144+ -d | --debug Exit after execution with exit codes (for testing)
145+ -c | --config Specify config file (default ~/.warprc)
146+ -q | --quiet Suppress all output
147+
148+ help Show this extremely helpful text
149 EOF
150 }
151
152@@ -131,10 +134,11 @@ wd_getdir()
153 wd_warp()
154 {
155 local point=$1
156+ local sub=$2
157
158 if [[ $point =~ "^\.+$" ]]
159 then
160- if [ $#1 < 2 ]
161+ if [[ $#1 < 2 ]]
162 then
163 wd_exit_warn "Warping to current directory?"
164 else
165@@ -143,7 +147,12 @@ wd_warp()
166 fi
167 elif [[ ${points[$point]} != "" ]]
168 then
169- cd ${points[$point]/#\~/$HOME}
170+ if [[ $sub != "" ]]
171+ then
172+ cd ${points[$point]/#\~/$HOME}/$sub
173+ else
174+ cd ${points[$point]/#\~/$HOME}
175+ fi
176 else
177 wd_exit_fail "Unknown warp point '${point}'"
178 fi
179@@ -154,6 +163,11 @@ wd_add()
180 local force=$1
181 local point=$2
182
183+ if [[ $point == "" ]]
184+ then
185+ point=$(basename $PWD)
186+ fi
187+
188 if [[ $point =~ "^[\.]+$" ]]
189 then
190 wd_exit_fail "Warp point cannot be just dots"
191@@ -163,10 +177,7 @@ wd_add()
192 elif [[ $point == *:* ]]
193 then
194 wd_exit_fail "Warp point cannot contain colons"
195- elif [[ $point == "" ]]
196- then