diff --git a/meson.build b/meson.build index c4fc23955b..5458267e34 100644 --- a/meson.build +++ b/meson.build @@ -404,6 +404,19 @@ if get_option('tests') subdir('tests') endif +if get_option('bash_completion') and host_machine.system() != 'windows' + bash_comp = dependency('bash_completion', required: false) + if bash_comp.found() + bash_install_dir = bash_comp.get_variable( + pkgconfig: 'completionsdir', + pkgconfig_define: ['datadir', datadir] + ) + else + bash_install_dir = join_paths(datadir, 'bash-completion', 'completions') + endif + install_data('tools/bash-completion.sh', install_dir: bash_install_dir, rename: 'aegisub') +endif + aegisub_cpp_pch = ['src/include/agi_pre.h'] aegisub_c_pch = ['src/include/agi_pre_c.h'] diff --git a/meson_options.txt b/meson_options.txt index 4c00f520f8..54c4c81a5c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,5 +26,6 @@ option('update_server', type: 'string', value: 'https://aegisub-updates.redvice. option('update_url', type: 'string', value: '/trunk', description: 'Base path to use for the update checker') option('build_osx_bundle', type: 'boolean', value: false, description: 'Package Aegisub.app on OSX') +option('bash_completion', type: 'boolean', value: true, description: 'Install bash shell completions') option('tests', type: 'boolean', value: true, description: 'Build tests') diff --git a/tools/bash-completion.sh b/tools/bash-completion.sh new file mode 100644 index 0000000000..87cbbeefb2 --- /dev/null +++ b/tools/bash-completion.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +complete -f -o plusdirs -X '!*.@(ass|ssa|mkv|mka|mks|sub|srt|ttxt|txt)' aegisub