Skip to content

Commit

Permalink
dev: only nested subdir for double dash leading completed dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed Oct 5, 2017
1 parent ede233f commit d851ff8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions __diraction-dispatch
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ local PWD=$dirdir
if (( CURRENT == 3 ));
then # Subcomand completion
case $subcommand in

/*) # Pattern :D
//*) # SubPattern :D
local pattern="$(echo $subcommand | sed -e 's:\(.\):\.*\1\.*:g')"
local cmd="cd $dirdir && ls -d **/*/ | sed -E 's:^:/:g' | grep \"$pattern\" "
local paths=("${(f)$(eval $cmd)}")
if [[ ${#paths} -gt 1 ]]; then
compadd -S '' -X "Matching Nested Subdirs" -U -a paths # -U no to filter non matching values
return 0
else
_message "No matching nested subdir"
return 1
fi
;;
/*) # Pattern
local pattern="$(echo $subcommand | sed -e 's:\(.\):\.*\1\.*:g')"
local cmd="cd $dirdir && ls -d */ | sed -E 's:^:/:g' | grep \"$pattern\" "
local paths=("${(f)$(eval $cmd)}")
if [[ ${#paths} -gt 1 ]]; then
compadd -S '' -X "Matching Subdirs" -U -a paths # -U no to filter non matching values
return 0
Expand Down

0 comments on commit d851ff8

Please sign in to comment.