[wd] Update to v0.4.1
This commit is contained in:
parent
c78277fd8b
commit
4533c7a31c
@ -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:
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user