cbb83cbc31af922330af2508276c1adbec391860
- Author
- Atk <atk@aaathats3as.com>
- Committer
- GitHub <noreply@github.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 a454a6c1eb43b8dc47807647452154c0b6e6c5ad..8791f9f0ee931413490282ae61c25f24a1b9145f 100644
3--- a/plugins/wd/README.md
4+++ b/plugins/wd/README.md
5@@ -2,19 +2,19 @@
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 inefficient 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`.
11+Why?
12+Because `cd` seems inefficient when the folder is frequently visited or has a long path.
13
14 
15
16-*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.
17-
18 ## Setup
19
20-### oh-my-zsh
21+### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
22
23-`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
24+`wd` comes bundled with oh-my-zsh!
25
26-Just add the plugin in your `~/.zshrc` file:
27+Just add the plugin in your `.zshrc` file:
28
29 ```zsh
30 plugins=(... wd)
31@@ -38,11 +38,21 @@ antibody bundle mfaerevaag/wd
32
33 ### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
34
35+1. Install from the AUR
36+
37 ```zsh
38 yay -S zsh-plugin-wd-git
39 # or use any other AUR helper
40 ```
41
42+2. Then add to your `.zshrc`:
43+
44+```zsh
45+wd() {
46+ . /usr/share/wd/wd.sh
47+}
48+```
49+
50 ### [zplug](https://github.com/zplug/zplug)
51
52 ```zsh
53@@ -51,7 +61,9 @@ zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS
54
55 ### Automatic
56
57-Run either in terminal:
58+_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)_
59+
60+Run either command in your terminal:
61
62 ```zsh
63 curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
64@@ -65,28 +77,33 @@ wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.
65
66 ### Manual
67
68-* Clone this repo to your liking
69+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):
70
71-* Add `wd` function to `.zshrc` (or `.profile` etc.):
72+```zsh
73+git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
74+```
75
76- ```zsh
77- wd() {
78- . ~/path/to/cloned/repo/wd/wd.sh
79- }
80- ```
81+2. Add `wd` function to `.zshrc` (or `.profile` etc.):
82
83-* Install manpage. From `wd`'s base directory (requires root permissions):
84+```zsh
85+wd() {
86+ . ~/.local/wd/wd.sh
87+}
88+```
89
90- ```zsh
91- cp wd.1 /usr/share/man/man1/wd.1
92- chmod 644 /usr/share/man/man1/wd.1
93- ```
94+3. Install manpage (optional):
95
96- **Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
97+```zsh
98+sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
99+sudo chmod 644 /usr/share/man/man1/wd.1
100+```
101+
102+**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
103
104 ## Completion
105diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
106index 618995c632f94535f7fd0c59eca346f45041d103..d5d38f25b285b956c7b39b5a197cf6a15c47be42 100644
107--- a/plugins/wd/wd.sh
108+++ b/plugins/wd/wd.sh
109@@ -8,7 +8,7 @@
110 # @github.com/mfaerevaag/wd
111
112 # version
113-readonly WD_VERSION=0.4.6
114+readonly WD_VERSION=0.5.0
115
116 # colors
117 readonly WD_BLUE="\033[96m"
118@@ -79,8 +79,6 @@ Commands:
119 <point> <path> Warps to the directory specified by the warp point with path appended
120 add <point> Adds the current working directory to your warp points
121 add Adds the current working directory to your warp points with current directory's name
122- add! <point> Overwrites existing warp point
123- add! Overwrites existing warp point with current directory's name
124 rm <point> Removes the given warp point
125 rm Removes the given warp point with current directory's name
126 show <point> Print path to given warp point
127@@ -88,12 +86,13 @@ Commands:
128 list Print all stored warp points
129 ls <point> Show files from given warp point (ls)
130 path <point> Show the path to given warp point (pwd)
131- clean! Remove points warping to nonexistent directories
132+ clean Remove points warping to nonexistent directories (will prompt unless --force is used)
133
134 -v | --version Print version
135 -d | --debug Exit after execution with exit codes (for testing)
136 -c | --config Specify config file (default ~/.warprc)
137 -q | --quiet Suppress all output
138+ -f | --force Allows overwriting without warning (for add & clean)
139
140 help Show this extremely helpful text
141 EOF
142@@ -103,7 +102,7 @@ wd_exit_fail()
143 {
144 local msg=$1
145
146- wd_print_msg $WD_RED $msg
147+ wd_print_msg "$WD_RED" "$msg"
148 WD_EXIT_CODE=1
149 }
150
151@@ -111,7 +110,7 @@ wd_exit_warn()
152 {
153 local msg=$1
154
155- wd_print_msg $WD_YELLOW $msg
156+ wd_print_msg "$WD_YELLOW" "$msg"
157 WD_EXIT_CODE=1
158 }
159
160@@ -119,7 +118,7 @@ wd_getdir()
161 {
162 local name_arg=$1
163
164- point=$(wd_show $name_arg)
165+ point=$(wd_show "$name_arg")
166 dir=${point:28+$#name_arg+7}
167
168 if [[ -z $name_arg ]]; then
169@@ -162,12 +161,12 @@ wd_warp()
170
171 wd_add()
172 {
173- local force=$1
174- local point=$2
175+ local point=$1
176+ local force=$2
177
178 if [[ $point == "" ]]
179 then
180- point=$(basename $PWD)
181+ point=$(basename "$PWD")
182 fi
183
184 if [[ $point =~ "^[\.]+$" ]]
185@@ -179,57 +178,59 @@ wd_add()
186 elif [[ $point == *:* ]]
187 then
188 wd_exit_fail "Warp point cannot contain colons"
189- elif [[ ${points[$point]} == "" ]] || $force
190+ elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
191 then
192- wd_remove $point > /dev/null
193- printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
194+ wd_remove "$point" > /dev/null
195+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$WD_CONFIG"
196 if (whence sort >/dev/null); then
197 local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
198 # use 'cat' below to ensure we respect $WD_CONFIG as a symlink
199- sort -o "${config_tmp}" $WD_CONFIG && cat "${config_tmp}" > $WD_CONFIG && rm "${config_tmp}"
200+ sort -o "${config_tmp}" "$WD_CONFIG" && cat "${config_tmp}" > "$WD_CONFIG" && rm "${config_tmp}"
201 fi
202
203 wd_export_static_named_directories
204
205- wd_print_msg $WD_GREEN "Warp point added"
206+ wd_print_msg "$WD_GREEN" "Warp point added"
207
208 # override exit code in case wd_remove did not remove any points