Skip to content

Commit

Permalink
Add support for bash-completion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
louisroyer committed Oct 4, 2024
1 parent 6b4a340 commit 27ed45f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,19 @@ subdir('po')
subdir('src')
subdir('tests')

if get_option('bash_completion')
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']

Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ option('update_server', type: 'string', value: 'https://updates.aegisub.org', de
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.')
2 changes: 2 additions & 0 deletions tools/bash-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
complete -f -o plusdirs -X '!*.@(ass|ssa|mkv|mka|mks|sub|srt|ttxt|txt)' aegisub

0 comments on commit 27ed45f

Please sign in to comment.