Skip to content

Commit

Permalink
untabify + note for /compl tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed May 23, 2015
1 parent 4619c6c commit 8a17cc2
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 291 deletions.
86 changes: 43 additions & 43 deletions __diraction-dispatch
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,59 @@ if (( CURRENT == 3));
then # Subcomand completion
case $subcommand in

/*) # Pattern :D
/*) # Pattern :D

local pattern="${subcommand#/}"
local cmd="$cd $dirdir && ls -d $pattern* 2>/dev/null | sed -E 's:^:/:g' | xargs echo"
# §maybe extract fund
# §todo: check no file are grabbed
compadd -x "Available subdirs:" $(eval $cmd)
return 0
;;
local pattern="${subcommand#/}"
local cmd="$cd $dirdir && ls -d $pattern* 2>/dev/null | sed -E 's:^:/:g' | xargs echo"
# §maybe extract fund
# §todo: dont add space: see http://stackoverflow.com/questions/8372866/how-to-remove-an-additional-space-from-zsh-auto-complete-function
compadd -x "Available subdirs:" $(eval $cmd)
return 0
;;

*) # Basic argument
local -a subcommands
subcommands=(
'ls:List files in the specified folder (alias l)'
'exec:Exec (through eval) the specified command (alias e - , _ )'
'interactive:Go in interactive mode, to perform several commands (alias i,prompt,shell)'
'/:Go in some of the subfolder if provided (alias c cd)'
'edit:Edit the given subfile (alias ed)'
'browser:Launch browser on the directory (alias b)'
'tree:Launch tree command (alias t)'
)
compadd -x "Whitelisted commands" $DIRACTION_DISPATCH_WHITELIST
# maybe extend subcommands with these value??
# or extend the array here?
*) # Basic argument
local -a subcommands
subcommands=(
'ls:List files in the specified folder (alias l)'
'exec:Exec (through eval) the specified command (alias e - , _ )'
'interactive:Go in interactive mode, to perform several commands (alias i,prompt,shell)'
'/:Go in some of the subfolder if provided (alias c cd)'
'edit:Edit the given subfile (alias ed)'
'browser:Launch browser on the directory (alias b)'
'tree:Launch tree command (alias t)'
)
compadd -x "Whitelisted commands" $DIRACTION_DISPATCH_WHITELIST
# maybe extend subcommands with these value??
# or extend the array here?

_describe -t commands "Dispatcher subcommand" subcommands
_describe -t commands "Dispatcher subcommand" subcommands

return
return
esac
else # argument completion
# completion won't be called without a 2 arg, so sure will be 4+
case $subcommand in
e|"exec") # maybe files?
_message "no completion, you are on your own!" && return 0 ;;
i|interactive|prompt|shell|help)
_message "Just hit enter, and enter the interactive mode :)" && return 0;;
e|"exec") # maybe files?
_message "no completion, you are on your own!" && return 0 ;;
i|interactive|prompt|shell|help)
_message "Just hit enter, and enter the interactive mode :)" && return 0;;

# §todo: no args
# §todo: no args

*)
local compfun="_${subcommand}"
shift words; shift words # shifting words args
if functions "$compfun" > /dev/null; then
# §tofix: git error: zsh:12: command not found: ___diraction-dispatch_main
# if so do it up
$compfun && return 0
# beware to file completion:
# https://github.com/robbyrussell/oh-my-zsh/issues/2394
else
# decide what to do.
_message "No completion available for $subcommand"
fi
;;
*)
local compfun="_${subcommand}"
shift words; shift words # shifting words args
if functions "$compfun" > /dev/null; then
# §tofix: git error: zsh:12: command not found: ___diraction-dispatch_main
# if so do it up
$compfun && return 0
# beware to file completion:
# https://github.com/robbyrussell/oh-my-zsh/issues/2394
else
# decide what to do.
_message "No completion available for $subcommand"
fi
;;
esac

fi
10 changes: 5 additions & 5 deletions _diraction
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ if (( CURRENT == 2 )); then
return 0
elif (( CURRENT == 3 )); then
case $words[2] in
create) _message "Diraction Name" && return 0;;
destroy|disable|enable|exist) compadd -x "Existing diractions" ${(ok)DIRACTION_REGISTER} && return 0;;
grep*) _message "Grepping pattern" && return 0;;
*) _message "No args required"
create) _message "Diraction Name" && return 0;;
destroy|disable|enable|exist) compadd -x "Existing diractions" ${(ok)DIRACTION_REGISTER} && return 0;;
grep*) _message "Grepping pattern" && return 0;;
*) _message "No args required"
esac

elif (( CURRENT == 4 )); then
case $words[2] in
create) _path_files -/ -x "Diraction Path" && return 0 ;;
create) _path_files -/ -x "Diraction Path" && return 0 ;;
esac
fi
Loading

0 comments on commit 8a17cc2

Please sign in to comment.