8a51bfd76b3dc747c92005cd941d790ed2c83ffd
- Author
- Robby Russell <robby@planetargon.com>
- 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 bc0ebe334ed4ed556d93c2a4c0876cd610f76579..bcfeab684f81eb98cb9f48957f1729d21ef35c97 100644
3--- a/plugins/wd/README.md
4+++ b/plugins/wd/README.md
5@@ -1,8 +1,60 @@
6-## wd
7+wd
8+==
9+
10+[](https://travis-ci.org/mfaerevaag/wd)
11+
12+`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.
13+
14+
15+### Setup
16+
17+### oh-my-zsh
18+
19+`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
20+
21+Just add the plugin in your `~/.zshrc` file:
22+
23+ plugins=(... wd)
24+
25+
26+#### Automatic
27+
28+Run either in terminal:
29+
30+ * `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`
31+
32+ * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
33+
34+
35+#### Manual
36+
37+ * Clone this repo to your liking
38+
39+ * Add `wd` function to `.zshrc` (or `.profile` etc.):
40+
41+ wd() {
42+ . ~/paht/to/wd/wd.sh
43+ }
44+
45+ * Install manpage. From `wd`'s base directory (requires root permissions):
46+
47+ # cp wd.1 /usr/share/man/man1/wd.1
48+ # chmod 644 /usr/share/man/man1/wd.1
49+
50+ Note, when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
51+
52+
53+#### Completion
54+
55diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
56index 0b03d8fff3b7f5a2578742736445b922da523df6..2bb58dd31b03f5b5e629ed6ede796fbd6195720c 100644
57--- a/plugins/wd/_wd.sh
58+++ b/plugins/wd/_wd.sh
59@@ -21,7 +21,8 @@ function _wd() {
60 'add!:Overwrites existing warp point'
61 'rm:Removes the given warp point'
62 'ls:Outputs all stored warp points'
63- 'show:Outputs all warp points that point to the current directory'
64+ 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
65+ 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
66 'help:Show this extremely helpful text'
67 '..:Go back to last directory'
68 )
69@@ -43,6 +44,9 @@ function _wd() {
70 add)
71 _message 'Write the name of your warp point' && ret=0
72 ;;
73+ show)
74+ _describe -t points "Warp points" warp_points && ret=0
75+ ;;
76 esac
77 ;;
78 esac
79diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
80index dfb9ad89a4dc3478112eb053a4f70088b34ec280..5ecbdc5035496dd1ec96e734800b45c594281019 100755
81--- a/plugins/wd/wd.sh
82+++ b/plugins/wd/wd.sh
83@@ -7,40 +7,108 @@
84 #
85 # @github.com/mfaerevaag/wd
86
87-
88-## variables
89-readonly CONFIG=$HOME/.warprc
90+# version
91+readonly WD_VERSION=0.4
92
93 # colors
94-readonly BLUE="\033[96m"
95-readonly GREEN="\033[92m"
96-readonly YELLOW="\033[93m"
97-readonly RED="\033[91m"
98-readonly NOC="\033[m"
99+readonly WD_BLUE="\033[96m"
100+readonly WD_GREEN="\033[92m"
101+readonly WD_YELLOW="\033[93m"
102+readonly WD_RED="\033[91m"
103+readonly WD_NOC="\033[m"
104
105+## functions
106
107-## init
108+# helpers
109+wd_yesorno()
110+{
111+ # variables
112+ local question="${1}"
113+ local prompt="${question} "
114+ local yes_RETVAL="0"
115+ local no_RETVAL="3"
116+ local RETVAL=""
117+ local answer=""
118+
119+ # read-eval loop
120+ while true ; do
121+ printf $prompt
122+ read -r answer
123+
124+ case ${answer:=${default}} in
125+ Y|y|YES|yes|Yes )
126+ RETVAL=${yes_RETVAL} && \
127+ break
128+ ;;
129+ N|n|NO|no|No )
130+ RETVAL=${no_RETVAL} && \
131+ break
132+ ;;
133+ * )
134+ echo "Please provide a valid answer (y or n)"
135+ ;;
136+ esac
137+ done
138
139-# check if config file exists
140-if [ ! -e $CONFIG ]
141-then
142- # if not, create config file
143- touch $CONFIG
144-fi
145+ return ${RETVAL}
146+}
147
148-# load warp points
149-typeset -A points
150-while read -r line
151-do
152- arr=(${(s,:,)line})
153- key=${arr[1]}
154- val=${arr[2]}
155+wd_print_msg()
156+{
157+ if [[ -z $wd_quiet_mode ]]
158+ then
159+ local color=$1
160+ local msg=$2
161
162- points[$key]=$val
163-done < $CONFIG
164+ if [[ $color == "" || $msg == "" ]]
165+ then
166+ print " ${WD_RED}*${WD_NOC} Could not print message. Sorry!"
167+ else
168+ print " ${color}*${WD_NOC} ${msg}"
169+ fi
170+ fi
171+}
172
173+wd_print_usage()
174+{
175+ cat <<- EOF
176+Usage: wd [command] <point>
177
178-## functions
179+Commands:
180+ add <point> Adds the current working directory to your warp points
181+ add! <point> Overwrites existing warp point
182+ rm <point> Removes the given warp point