From 5cf72167740d984172496efbf6a644b6c5194947 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 9 Jun 2017 11:38:20 -0400 Subject: [PATCH] zsh and fish completions optparse-applicative-0.14.0.0 adds support for these, so have the Makefile install their scripts when built with it. CmdLine/GitAnnex/Options.hs now uses action "file" in cmdParams, which affects the bash and zsh completions, letting them complete filenames for subcommands that use that. This is not needed for bash, since bash-completion.bash enables -o bashdefault, which lets it complete filenames too. But it does not seem to break the bash completions. It is needed for zsh; the zsh completion otherwise does not complete filenames. The fish completion will always complete filenames no matter what. Messy. This commit was sponsored by Denis Dzyubenko on Patreon. --- CHANGELOG | 2 ++ CmdLine/GitAnnex/Options.hs | 1 + Makefile | 12 +++++++++--- ...mment_1_a810be47633dc83d737a9ef6e8870431._comment | 12 ++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 doc/tips/ZSH_completion/comment_1_a810be47633dc83d737a9ef6e8870431._comment diff --git a/CHANGELOG b/CHANGELOG index 791034fe85..d84b3cb8c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,8 @@ git-annex (6.20170520) UNRELEASED; urgency=medium * assistant: Merge changes from refs/remotes/foo/master into master. Previously, only sync branches were merged. This makes regular git push into a repository watched by the assistant auto-merge. + * Makefile: Install completions for the fish and zsh shells + when git-annex is built with optparse-applicative-0.14. -- Joey Hess Wed, 24 May 2017 14:03:40 -0400 diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index aad0536d8d..04f24367ca 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -97,6 +97,7 @@ gitAnnexGlobalOptions = commonGlobalOptions ++ cmdParams :: CmdParamsDesc -> Parser CmdParams cmdParams paramdesc = many $ argument str ( metavar paramdesc + <> action "file" ) parseAutoOption :: Parser Bool diff --git a/Makefile b/Makefile index 8ab031c5ea..7d5c70148f 100644 --- a/Makefile +++ b/Makefile @@ -62,10 +62,16 @@ install-bins: build ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-tor-annex -install-misc: Build/InstallDesktopFile +install-misc: build Build/InstallDesktopFile ./Build/InstallDesktopFile $(PREFIX)/bin/git-annex || true - install -d $(DESTDIR)$(PREFIX)/share/bash-completion/completions - install -m 0644 bash-completion.bash $(DESTDIR)$(PREFIX)/share/bash-completion/completions/git-annex + install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions + install -m 0644 bash-completion.bash $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions/git-annex + install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/zsh/vendor-completions + @./git-annex --zsh-completion-script git-annex > $(DESTDIR)$(PREFIX)/$(SHAREDIR)/zsh/vendor-completions/_git-annex || \ + echo "** zsh completions not installed; built with too old version of optparse-applicative" + install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/fish/completions + @./git-annex --fish-completion-script git-annex > $(DESTDIR)$(PREFIX)/$(SHAREDIR)/fish/completions/git-annex.fish || \ + echo "** fish completions not installed; built with too old version of optparse-applicative" install: install-bins install-docs install-misc diff --git a/doc/tips/ZSH_completion/comment_1_a810be47633dc83d737a9ef6e8870431._comment b/doc/tips/ZSH_completion/comment_1_a810be47633dc83d737a9ef6e8870431._comment new file mode 100644 index 0000000000..c3c12ab318 --- /dev/null +++ b/doc/tips/ZSH_completion/comment_1_a810be47633dc83d737a9ef6e8870431._comment @@ -0,0 +1,12 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-06-09T15:34:59Z" + content=""" +When git-annex is built with optparse-applicative version 0.14.0.0, +it can generate its own zsh completion file. The Makefile installs that, +and it seems to work well. + +So, I think that the hand-built zsh completions won't need to be maintained +much longer! +"""]]