diff options
-rw-r--r-- | CmdLine/GitAnnex/Options.hs | 2 | ||||
-rw-r--r-- | bash-completion.bash | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index 06b153295..b9c0fe7b7 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -89,8 +89,6 @@ gitAnnexGlobalOptions = commonGlobalOptions ++ cmdParams :: CmdParamsDesc -> Parser CmdParams cmdParams paramdesc = many $ argument str ( metavar paramdesc - -- Let bash completion complete files - <> action "file" ) parseAutoOption :: Parser Bool diff --git a/bash-completion.bash b/bash-completion.bash index b0367c030..11f9ff810 100644 --- a/bash-completion.bash +++ b/bash-completion.bash @@ -1,7 +1,19 @@ # Use git-annex's built-in bash completion # This bash completion is generated by the option parser, so it covers all # commands, all options, and will never go out of date! -source <(git-annex --bash-completion-script git-annex) +_git-annex() +{ + local cmdline + CMDLINE=(--bash-completion-index $COMP_CWORD) + + for arg in ${COMP_WORDS[@]}; do + CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg) + done + + COMPREPLY=( $(git-annex "${CMDLINE[@]}") ) +} + +complete -o bashdefault -o default -o filenames -F _git-annex git-annex # Called by git's bash completion script when completing "git annex" _git_annex() { |