[wd] Update to v0.4.1

This commit is contained in:
Markus Faerevaag 2015-01-26 00:13:39 +01:00
commit 4533c7a31c
3 changed files with 65 additions and 8 deletions

View file

@ -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