Skip to content

Commit 0f0547e

Browse files
committed
Add support for bash-completion
This allows autocomplete when calling aegisub from terminal. Before this commit, when having for example `file.webm` and `file.ass` in the directory, both were proposed while only the later could be open using CLI argument.
1 parent 18175e4 commit 0f0547e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

meson.build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,19 @@ if get_option('tests')
404404
subdir('tests')
405405
endif
406406

407+
if get_option('bash_completion')
408+
bash_comp = dependency('bash_completion', required: false)
409+
if bash_comp.found()
410+
bash_install_dir = bash_comp.get_variable(
411+
pkgconfig: 'completionsdir',
412+
pkgconfig_define: ['datadir', datadir]
413+
)
414+
else
415+
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
416+
endif
417+
install_data('tools/bash-completion.sh', install_dir: bash_install_dir, rename: 'aegisub')
418+
endif
419+
407420
aegisub_cpp_pch = ['src/include/agi_pre.h']
408421
aegisub_c_pch = ['src/include/agi_pre_c.h']
409422

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ option('update_server', type: 'string', value: 'https://aegisub-updates.redvice.
2626
option('update_url', type: 'string', value: '/trunk', description: 'Base path to use for the update checker')
2727

2828
option('build_osx_bundle', type: 'boolean', value: false, description: 'Package Aegisub.app on OSX')
29+
option('bash_completion', type: 'boolean', value: true, description: 'Install bash shell completions')
2930

3031
option('tests', type: 'boolean', value: true, description: 'Build tests')

tools/bash-completion.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
complete -f -o plusdirs -X '!*.@(ass|ssa|mkv|mka|mks|sub|srt|ttxt|txt)' aegisub

0 commit comments

Comments
 (0)