Skip to content

Commit 521be31

Browse files
DogeTheBeastN-R-K
authored andcommitted
build: add auto-completion installation
1 parent 0af6d20 commit 521be31

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ EXTRA_DIST = $(man_MANS) autogen.sh deps.pc etc
4242

4343
SUBDIRS = src
4444

45+
if BASH
46+
bashcompletiondir = @bash_completion_dir@
47+
bashcompletion_DATA = etc/bash-completion/scrot
48+
endif
49+
50+
if ZSH
51+
zshcompletiondir = @zsh_completion_dir@
52+
zshcompletion_DATA = etc/zsh-completion/_scrot
53+
endif
54+
4555
distclean-local:
4656
-rm -rf autom4te.cache/
4757

TODO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Look for any bugs reported downstream or in our github issues and fix them:
1717
- ~~Filter out mutually exclusive options in zsh completion. E.g if `-b` is
1818
already provided then `--border` should no longer be considered a potential
1919
match.~~
20-
- Add some way to install zsh/bash completion scripts. Since the directory where
20+
- ~~Add some way to install zsh/bash completion scripts. Since the directory where
2121
completion script go into can vary, we want the user to explicitly set the
2222
installation directory. E.g via the configure script
23-
`./configure --with-zsh-completion-path=...`.
23+
`./configure --with-zsh-completion-path=...`.~~
2424

2525
## Switch to newer Imlib2 interfaces
2626

configure.ac

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ AC_PROG_MAKE_SET
1919

2020
AM_MAINTAINER_MODE
2121

22+
# Install bash completion script
23+
AC_ARG_WITH([bash-completion-path],
24+
[AS_HELP_STRING([--with-bash-completion-path=DIR],
25+
[Custom installation directory for the bash completion script (Default=/usr/share/bash-completion/completions)])],
26+
[bash_completion_dir="$withval"],
27+
[bash_completion_dir="/usr/share/bash-completion/completions"])
28+
29+
# Install zsh completion script
30+
AC_ARG_WITH([zsh-completion-path],
31+
[AS_HELP_STRING([--with-zsh-completion-path=DIR],
32+
[Custom installation directory for the zsh completion script (Default=/usr/share/zsh/site-functions)])],
33+
[zsh_completion_dir="$withval"],
34+
[zsh_completion_dir="/usr/share/zsh/site-functions"])
35+
2236
m4_pattern_forbid([^AX_],[=> GNU autoconf-archive not present. <=])
2337
AS_IF([test "x$orig_CFLAGS" = "x"], [
2438
CFLAGS=""
@@ -61,8 +75,14 @@ AS_IF([test "x$LIBBSD_NEEDED" = "xyes"], [
6175
[AC_MSG_ERROR([BSD functions not found, libbsd is required])])
6276
])
6377

78+
AM_CONDITIONAL(BASH, [test "x$bash_completion_dir" != "xno"])
79+
AM_CONDITIONAL(ZSH, [test "x$zsh_completion_dir" != "xno"])
80+
6481
AC_SUBST([LIBS], ["$SCROT_DEPS_LIBS $LIBBSD_LIBS $LIBS"])
6582
AC_SUBST([CPPFLAGS], ["$SCROT_DEPS_CFLAGS $LIBBSD_CFLAGS $CPPFLAGS"])
6683

84+
AC_SUBST([bash_completion_dir])
85+
AC_SUBST([zsh_completion_dir])
86+
6787
AC_CONFIG_FILES([Makefile src/Makefile])
6888
AC_OUTPUT

0 commit comments

Comments
 (0)