From 24a69df9abaa932a1dcba9d3fb8aebcb3d44db3e Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 9 May 2025 23:35:29 +0200 Subject: [PATCH] etc: make the new bash-completion file work for all variants of our executables. In particular make it also work with the `gimp-console` and with all symlink names. Also rename the bash completion file using the full application version so that it will be possible to install several such completion files side by side. --- etc/{bash_completion => bash_completion.in} | 18 ++++++++++++++++-- etc/meson.build | 18 ++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) rename etc/{bash_completion => bash_completion.in} (82%) diff --git a/etc/bash_completion b/etc/bash_completion.in similarity index 82% rename from etc/bash_completion rename to etc/bash_completion.in index ea09863978..eb27cc5bad 100644 --- a/etc/bash_completion +++ b/etc/bash_completion.in @@ -1,4 +1,3 @@ - __gimp() { COMPREPLY=() @@ -73,4 +72,19 @@ __gimp() return 0 } -complete -F __gimp gimp +complete -F __gimp @GIMP_MAIN_EXE@ +if command -v @GIMP_SYMLINK1@ 2>&1 > /dev/null +then + complete -F __gimp @GIMP_SYMLINK1@ + complete -F __gimp @GIMP_SYMLINK2@ +fi + +if command -v @GIMP_CONSOLE_EXE@ 2>&1 > /dev/null +then + complete -F __gimp @GIMP_CONSOLE_EXE@ + if command -v @GIMP_CONSOLE_SYMLINK1@ 2>&1 > /dev/null + then + complete -F __gimp @GIMP_CONSOLE_SYMLINK1@ + complete -F __gimp @GIMP_CONSOLE_SYMLINK2@ + fi +fi diff --git a/etc/meson.build b/etc/meson.build index 74cb342897..a1a0bd8538 100644 --- a/etc/meson.build +++ b/etc/meson.build @@ -36,8 +36,18 @@ if have_bash bash_comp_inst_dir = get_option('datadir') / 'bash-completion' / 'completions' endif - install_data('bash_completion', - install_dir: bash_comp_inst_dir, - rename: 'gimp', - ) + bash_completion_conf = configuration_data() + bash_completion_conf.set('GIMP_MAIN_EXE', gimpmain_exe_name) + bash_completion_conf.set('GIMP_SYMLINK1', 'gimp-' + gimp_app_version_major.to_string()) + bash_completion_conf.set('GIMP_SYMLINK2', 'gimp') + + bash_completion_conf.set('GIMP_CONSOLE_EXE', gimpconsole_exe_name) + bash_completion_conf.set('GIMP_CONSOLE_SYMLINK1', 'gimp-console-' + gimp_app_version_major.to_string()) + bash_completion_conf.set('GIMP_CONSOLE_SYMLINK2', 'gimp-console') + + configure_file(input : 'bash_completion.in', + output: 'gimp-' + gimp_app_version, + configuration: bash_completion_conf, + install: true, + install_dir: bash_comp_inst_dir) endif