summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2015-02-22 10:15:08 -0800
committerRobby Russell <robby@planetargon.com>2015-02-22 10:15:08 -0800
commitbe63e8b7767c8249c1b71b2a2979bcdcbab58496 (patch)
tree2ad2da706be8374cb4a3759604e627d63f8a9a63
parent6809b42b65615019a182d0f0288ffc6d702ff7f9 (diff)
parent4533c7a31c737622782ce3233d2eb536f9cb4f2e (diff)
downloadzsh-be63e8b7767c8249c1b71b2a2979bcdcbab58496.tar.gz
zsh-be63e8b7767c8249c1b71b2a2979bcdcbab58496.tar.bz2
zsh-be63e8b7767c8249c1b71b2a2979bcdcbab58496.zip
Merge pull request #3518 from mfaerevaag/master
[wd] Update to v0.4.1
-rw-r--r--plugins/wd/README.md14
-rw-r--r--plugins/wd/_wd.sh13
-rwxr-xr-xplugins/wd/wd.sh46
3 files changed, 65 insertions, 8 deletions
diff --git a/plugins/wd/README.md b/plugins/wd/README.md
index bcfeab684..ed149eb3e 100644
--- a/plugins/wd/README.md
+++ b/plugins/wd/README.md
@@ -5,6 +5,8 @@ wd
`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.
+*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem.
+
### Setup
@@ -33,7 +35,7 @@ Run either in terminal:
* Add `wd` function to `.zshrc` (or `.profile` etc.):
wd() {
- . ~/paht/to/wd/wd.sh
+ . ~/path/to/cloned/repo/wd/wd.sh
}
* Install manpage. From `wd`'s base directory (requires root permissions):
@@ -84,7 +86,15 @@ Also, you may have to force a rebuild of `zcompdump` by running:
* List all warp points (stored in `~/.warprc`):
- $ wd ls
+ $ wd list
+
+ * List files in given warp point:
+
+ $ wd ls foo
+
+ * Show path of given warp point:
+
+ $ wd path foo
* List warp points to current directory, or optionally, path to given warp point:
diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
index 2bb58dd31..b67f4a1e2 100644
--- a/plugins/wd/_wd.sh
+++ b/plugins/wd/_wd.sh
@@ -20,10 +20,13 @@ function _wd() {
'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point'
'rm:Removes the given warp point'
- 'ls:Outputs all stored warp points'
- 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
+ 'list:Outputs all stored warp points'
+ 'ls:Show files from given warp point'
+ 'path:Show path to given warp point'
'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
'help:Show this extremely helpful text'
+ 'clean:Remove points warping to nonexistent directories'
+ 'clean!:Remove nonexistent directories without confirmation'
'..:Go back to last directory'
)
@@ -47,6 +50,12 @@ function _wd() {
show)
_describe -t points "Warp points" warp_points && ret=0
;;
+ ls)
+ _describe -t points "Warp points" warp_points && ret=0
+ ;;
+ path)
+ _describe -t points "Warp points" warp_points && ret=0
+ ;;
esac
;;
esac
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 5ecbdc503..3b9548168 100755
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -80,7 +80,9 @@ Commands:
rm <point> Removes the given warp point
show Print warp points to current directory
show <point> Print path to given warp point
- ls Print all stored warp points
+ list Print all stored warp points
+ls <point> Show files from given warp point
+path <point> Show the path to given warp point
clean! Remove points warping to nonexistent directories
-v | --version Print version
@@ -96,7 +98,7 @@ wd_exit_fail()
{
local msg=$1
- wd_print_msg $WD_RED $1
+ wd_print_msg $WD_RED $msg
WD_EXIT_CODE=1
}
@@ -108,6 +110,22 @@ wd_exit_warn()
WD_EXIT_CODE=1
}
+wd_getdir()
+{
+ local name_arg=$1
+
+ point=$(wd_show $name_arg)
+ dir=${point:28+$#name_arg+7}
+
+ if [[ -z $name_arg ]]; then
+ wd_exit_fail "You must enter a warp point"
+ break
+ elif [[ -z $dir ]]; then
+ wd_exit_fail "Unknown warp point '${name_arg}'"
+ break
+ fi
+}
+
# core
wd_warp()
@@ -201,6 +219,18 @@ wd_list_all()
done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG)
}
+wd_ls()
+{
+ wd_getdir $1
+ ls $dir
+}
+
+wd_path()
+{
+ wd_getdir $1
+ echo $(echo $dir | sed "s:${HOME}:~:g")
+}
+
wd_show()
{
local name_arg=$1
@@ -316,7 +346,7 @@ do
done < $WD_CONFIG
# get opts
-args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,ls,help,show -- $*)
+args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,list,ls:,path:,help,show -- $*)
# check if no arguments were given, and that version is not set
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
@@ -349,10 +379,18 @@ else
wd_remove $2
break
;;
- -l|--list|ls)
+ -l|list)
wd_list_all
break
;;
+ -ls|ls)
+ wd_ls $2
+ break
+ ;;
+ -p|--path|path)
+ wd_path $2
+ break
+ ;;
-h|--help|help)
wd_print_usage
break