Diff
1diff --git a/plugins/wd/README.md b/plugins/wd/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..f9f4e7ac1f5fd6ff0e9d606779fe052ea6d8458a
4--- /dev/null
5+++ b/plugins/wd/README.md
6@@ -0,0 +1,38 @@
7+## wd
8+
9+**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag)
10+
11+`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)
12+
13+### Usage
14+
15+ * Add warp point to current working directory:
16+
17+ wd add test
18+
19+ If a warp point with the same name exists, use `add!` to overwrite it.
20+
21+ * From an other directory, warp to test with:
22+
23+ wd test
24+
25+ * You can warp back to previous directory, and so on, with the puncticulation syntax:
26+
27+ wd ..
28+ wd ...
29+
30+ This is a wrapper for the zsh `dirs` function.
31+
32+ * Remove warp point test point:
33+
34+ wd rm test
35+
36+ * List warp points to current directory (stored in `~/.warprc`):
37+
38+ wd show
39+
40+ * List all warp points (stored in `~/.warprc`):
41+
42+ wd ls
43+
44+ * Print usage with no opts or the `help` argument.
45diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
46new file mode 100644
47index 0000000000000000000000000000000000000000..9505644356e0146cbdb8dbd1e422de9bc156ab36
48--- /dev/null
49+++ b/plugins/wd/_wd.sh
50@@ -0,0 +1,48 @@
51+#compdef wd.sh
52+
53+zstyle ":completion:*:descriptions" format "%B%d%b"
54+
55+CONFIG=$HOME/.warprc
56+
57+local -a main_commands
58+main_commands=(
59+ add:'Adds the current working directory to your warp points'
60+ #add'\!':'Overwrites existing warp point' # TODO: Fix
61+ rm:'Removes the given warp point'
62+ ls:'Outputs all stored warp points'
63+ show:'Outputs warp points to current directory'
64+)
65+
66+local -a points
67+while read line
68+do
69+ points+=$(awk "{ gsub(/\/Users\/$USER|\/home\/$USER/,\"~\"); print }" <<< $line)
70+done < $CONFIG
71+
72+_wd()
73+{
74+ # init variables
75+ local curcontext="$curcontext" state line
76+ typeset -A opt_args
77+
78+ # init state
79+ _arguments \
80+ '1: :->command' \
81+ '2: :->argument'
82+
83+ case $state in
84+ command)
85+ compadd "$@" add rm ls show
86+ _describe -t warp-points 'Warp points:' points && ret=0
87+ ;;
88+ argument)
89+ case $words[2] in
90+ rm|add!)
91+ _describe -t warp-points 'warp points' points && ret=0
92+ ;;
93+ *)
94+ esac
95+ esac
96+}
97+
98+_wd "$@"
99diff --git a/plugins/wd2/wd2/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh
100rename from plugins/wd2/wd2/wd.plugin.zsh
101rename to plugins/wd/wd.plugin.zsh
102index e0846ffd9037c95969453445002d2e52ca278eba..bbec4a7154a58572d74e389251ee1d4747c1aa5a 100755
103--- a/plugins/wd2/wd2/wd.plugin.zsh
104+++ b/plugins/wd/wd.plugin.zsh
105@@ -6,4 +6,4 @@
106 #
107 # @github.com/mfaerevaag/wd
108
109-alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh'
110+alias wd='. $ZSH/plugins/wd/wd.sh'
111diff --git a/plugins/wd2/wd2/wd.sh b/plugins/wd/wd.sh
112rename from plugins/wd2/wd2/wd.sh
113rename to plugins/wd/wd.sh
114index 7852028c061c8a96f411ecf286afa01b82e5e6aa..744f58bc2039a5e1c6054a5ad0aab77fa2aa165f 100755
115--- a/plugins/wd2/wd2/wd.sh
116+++ b/plugins/wd/wd.sh
117@@ -19,6 +19,13 @@ RED="\033[91m"
118 NOC="\033[m"
119
120
121+# check if config file exists
122+if [[ ! -a $CONFIG ]]
123+then
124+ # if not: create config file
125+ touch $CONFIG
126+fi
127+
128 ## load warp points
129 typeset -A points
130 while read line
131@@ -120,11 +127,12 @@ wd_print_msg()
132
133 wd_print_usage()
134 {
135- print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>"
136+ print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>"
137 print "\nCommands:"
138 print "\t add \t Adds the current working directory to your warp points"
139 print "\t add! \t Overwrites existing warp point"
140 print "\t remove Removes the given warp point"
141+ print "\t show \t Outputs warp points to current directory"
142 print "\t list \t Outputs all stored warp points"
143 print "\t help \t Show this extremely helpful text"
144 }
145@@ -135,13 +143,20 @@ wd_print_usage()
146 # get opts
147 args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*`
148
149+# check if no arguments were given
150 if [[ $? -ne 0 || $#* -eq 0 ]]
151 then
152 wd_print_usage
153-else
154- # can't exit, as this would exit the excecuting shell
155- # e.i. your terminal
156
157+# check if config file is writeable
158+elif [[ ! -w $CONFIG ]]
159+then
160+ wd_print_msg $RED "\'$CONFIG\' is not writeable."
161+ # do nothing => exit
162+ # can't run `exit`, as this would exit the executing shell
163+ # i.e. your terminal
164+
165+else
166 #set -- $args # WTF
167
168 for i