be63e8b7767c8249c1b71b2a2979bcdcbab58496

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #3518 from mfaerevaag/master

[wd] Update to v0.4.1

Diff

  1diff --git a/plugins/wd/README.md b/plugins/wd/README.md
  2index bcfeab684f81eb98cb9f48957f1729d21ef35c97..ed149eb3ed3e5e8414b6edea3d7cbbdcf1c8b467 100644
  3--- a/plugins/wd/README.md
  4+++ b/plugins/wd/README.md
  5@@ -5,6 +5,8 @@ wd
  6 
  7 `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.
  8 
  9+*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem.
 10+
 11 
 12 ### Setup
 13 
 14@@ -33,7 +35,7 @@ Run either in terminal:
 15  * Add `wd` function to `.zshrc` (or `.profile` etc.):
 16 
 17         wd() {
 18-            . ~/paht/to/wd/wd.sh
 19+            . ~/path/to/cloned/repo/wd/wd.sh
 20         }
 21 
 22  * Install manpage. From `wd`'s base directory (requires root permissions):
 23@@ -84,7 +86,15 @@ Also, you may have to force a rebuild of `zcompdump` by running:
 24 
 25  * List all warp points (stored in `~/.warprc`):
 26 
 27-        $ wd ls
 28+        $ wd list
 29+
 30+ * List files in given warp point:
 31+
 32+        $ wd ls foo
 33+
 34+ * Show path of given warp point:
 35+
 36+        $ wd path foo
 37 
 38  * List warp points to current directory, or optionally, path to given warp point:
 39 
 40diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
 41index 2bb58dd31b03f5b5e629ed6ede796fbd6195720c..b67f4a1e25599983bb592ca88545d6b626958f82 100644
 42--- a/plugins/wd/_wd.sh
 43+++ b/plugins/wd/_wd.sh
 44@@ -20,10 +20,13 @@ function _wd() {
 45     'add:Adds the current working directory to your warp points'
 46     'add!:Overwrites existing warp point'
 47     'rm:Removes the given warp point'
 48-    'ls:Outputs all stored warp points'
 49-    'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
 50+    'list:Outputs all stored warp points'
 51+    'ls:Show files from given warp point'
 52+    'path:Show path to given warp point'
 53     'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
 54     'help:Show this extremely helpful text'
 55+    'clean:Remove points warping to nonexistent directories'
 56+    'clean!:Remove nonexistent directories without confirmation'
 57     '..:Go back to last directory'
 58   )
 59 
 60@@ -47,6 +50,12 @@ function _wd() {
 61         show)
 62           _describe -t points "Warp points" warp_points && ret=0
 63           ;;
 64+        ls)
 65+          _describe -t points "Warp points" warp_points && ret=0
 66+          ;;
 67+        path)
 68+          _describe -t points "Warp points" warp_points && ret=0
 69+          ;;
 70       esac
 71       ;;
 72   esac
 73diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
 74index 5ecbdc5035496dd1ec96e734800b45c594281019..3b9548168c13c0a4ef907052f9d66e1b1ce02586 100755
 75--- a/plugins/wd/wd.sh
 76+++ b/plugins/wd/wd.sh
 77@@ -80,7 +80,9 @@ Commands:
 78 	rm <point>	Removes the given warp point
 79 	show		Print warp points to current directory
 80 	show <point>	Print path to given warp point
 81-	ls		Print all stored warp points
 82+	list	        Print all stored warp points
 83+ls  <point>     Show files from given warp point
 84+path <point>    Show the path to given warp point
 85 	clean!		Remove points warping to nonexistent directories
 86 
 87 	-v | --version	Print version
 88@@ -96,7 +98,7 @@ wd_exit_fail()
 89 {
 90     local msg=$1
 91 
 92-    wd_print_msg $WD_RED $1
 93+    wd_print_msg $WD_RED $msg
 94     WD_EXIT_CODE=1
 95 }
 96 
 97@@ -108,6 +110,22 @@ wd_exit_warn()
 98     WD_EXIT_CODE=1
 99 }
100 
101+wd_getdir()
102+{
103+    local name_arg=$1
104+
105+    point=$(wd_show $name_arg)
106+    dir=${point:28+$#name_arg+7}
107+
108+    if [[ -z $name_arg ]]; then
109+        wd_exit_fail "You must enter a warp point"
110+        break
111+    elif [[ -z $dir ]]; then
112+        wd_exit_fail "Unknown warp point '${name_arg}'"
113+        break
114+    fi
115+}
116+
117 # core
118 
119 wd_warp()
120@@ -201,6 +219,18 @@ wd_list_all()
121     done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG)
122 }
123 
124+wd_ls()
125+{
126+    wd_getdir $1
127+    ls $dir
128+}
129+
130+wd_path()
131+{
132+    wd_getdir $1
133+    echo $(echo $dir | sed "s:${HOME}:~:g")
134+}
135+
136 wd_show()
137 {
138     local name_arg=$1
139@@ -316,7 +346,7 @@ do
140 done < $WD_CONFIG
141 
142 # get opts
143-args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,ls,help,show -- $*)
144+args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,list,ls:,path:,help,show -- $*)
145 
146 # check if no arguments were given, and that version is not set
147 if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
148@@ -349,10 +379,18 @@ else
149                 wd_remove $2
150                 break
151                 ;;
152-            -l|--list|ls)
153+            -l|list)
154                 wd_list_all
155                 break
156                 ;;
157+            -ls|ls)
158+                wd_ls $2
159+                break
160+                ;;
161+            -p|--path|path)
162+                wd_path $2
163+                break
164+                ;;
165             -h|--help|help)
166                 wd_print_usage
167                 break