Skip to content

Commit 3d0d81d

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 d185d07 commit 3d0d81d

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
@@ -384,6 +384,19 @@ subdir('po')
384384
subdir('src')
385385
subdir('tests')
386386

387+
if get_option('bash_completion')
388+
bash_comp = dependency('bash_completion', required: false)
389+
if bash_comp.found()
390+
bash_install_dir = bash_comp.get_variable(
391+
pkgconfig: 'completionsdir',
392+
pkgconfig_define: ['datadir', datadir]
393+
)
394+
else
395+
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
396+
endif
397+
install_data('tools/bash-completion.sh', install_dir: bash_install_dir, rename: 'aegisub')
398+
endif
399+
387400
aegisub_cpp_pch = ['src/include/agi_pre.h']
388401
aegisub_c_pch = ['src/include/agi_pre_c.h']
389402

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ 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')

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)