[Scummvm-git-logs] scummvm master -> f90ebc3de93d7b50e1a95a0d208f8c0c63b139ef
bluegr
noreply at scummvm.org
Thu Feb 20 11:59:11 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f90ebc3de9 DISTS: Add Bash tab completions script for ScummVM
Commit: f90ebc3de93d7b50e1a95a0d208f8c0c63b139ef
https://github.com/scummvm/scummvm/commit/f90ebc3de93d7b50e1a95a0d208f8c0c63b139ef
Author: Torbjörn Andersson (eriktorbjorn at telia.com)
Date: 2025-02-20T13:59:07+02:00
Commit Message:
DISTS: Add Bash tab completions script for ScummVM
This is just an initial version that hopefully contains all the plumbing
to easily add what we want. Note that I've never written a tab
completions script before, and Bash scripting isn't my forte to begin
with. If it's correct, it's thanks to all the examples I've looked at.
If it's wrong, it's my own fault.
Changed paths:
A dists/bash-completions/README
A dists/bash-completions/scummvm
diff --git a/dists/bash-completions/README b/dists/bash-completions/README
new file mode 100644
index 00000000000..ab392ea66e7
--- /dev/null
+++ b/dists/bash-completions/README
@@ -0,0 +1,24 @@
+Custom Tab completions for the bash shell. This depends on the
+bash-completion package. Consult the documentation for that for how to
+enable this.
+
+Example for how to enable it for a single user in Debian GNU/Linux:
+
+If your ~/.bashrc was automatically generated, it probably contains
+something like this:
+
+ # enable programmable completion features (you don't need to enable
+ # this, if it's already enabled in /etc/bash.bashrc and /etc/profiles
+ # sources /etc/bash.bashrc).
+ # if [ -f /etc/bash_completion ]; then
+ # . /etc/bash_completion
+ # fi
+
+Uncomment the last three lines. This will enable the custom tab completions
+for everything included in the bash-completion package.
+
+Create ~/.local/share/bash-completions/completions if you don't
+already have it, and copy the tab completion script (scummvm) to it.
+Any newly started Bash shell should now have custom completions for
+ScummVM. You can also run "source ~/.bashrc" to update your current
+shell process.
diff --git a/dists/bash-completions/scummvm b/dists/bash-completions/scummvm
new file mode 100644
index 00000000000..4fa5df8c9b2
--- /dev/null
+++ b/dists/bash-completions/scummvm
@@ -0,0 +1,86 @@
+_scummvm()
+{
+ local opt_name
+ _init_completion || return
+
+ # If it's in the middle of a long option, offer completions for that. I'm
+ # adding these as an example until we figure which ones we want.
+
+ if [[ ${cur} == --* ]]; then
+ COMPREPLY=($(compgen -W "--debugflags= --debug-channels-only" -- "${cur}"))
+
+ # If the match ends with "=" we want to continue typing from there
+ # without any space at the end. This seems a bit peculiar to me, because
+ # it will apply to multiple matches, but it's the way that was suggested
+ # to me.
+
+ if [[ ${COMPREPLY[@]} =~ "=" ]]; then
+ compopt -o nospace
+ fi
+
+ return;
+ fi
+
+ # Handle command line options. Short options are converted into their long
+ # form, and for long options we extract the option being used. At the point
+ # where we can do tab completion on a long option, ${prev} will be "=" so
+ # we have to look further back.
+
+ case ${prev} in
+ -e)
+ opt_name=music-driver
+ ;;
+ =)
+ opt_name=${COMP_WORDS[COMP_CWORD-2]}
+ if [[ ${opt_name} != --* ]]; then
+ return;
+ fi
+ opt_name="${opt_name#--}"
+ ;;
+ esac
+
+ # If it's not an option, try matching a target from the scummvm.init file.
+
+ if [[ -z ${opt_name} ]] && [[ ${cur} != -* ]]; then
+ local scummvm_config
+
+ # Try our old, now downright ancient, configuration path
+ scummvm_config=${HOME}/.scummvmrc
+
+ if [[ ! -f ${scummvm_config} ]]; then
+ if [[ -n ${XDG_CONFIG_HOME} ]]; then
+ scummvm_config=${XDG_CONFIG_HOME}/scummvm/scummvm.ini
+ elif [[ -n ${HOME} ]]; then
+ scummvm_config=${HOME}/.config/scummvm/scummvm.ini
+ else
+ return;
+ fi
+ fi
+
+ if [[ -f ${scummvm_config} ]]; then
+ games=$(sed -n '/^\[scummvm\]/!s/^\[\([^]]*\)\]/\1/p' ${scummvm_config})
+ COMPREPLY=($(compgen -W "${games}" -- "${cur}"))
+ fi
+
+ return;
+ fi
+
+ # Completions for various option values. Not everything, just the ones I
+ # thought were the most useful.
+
+ local opts
+
+ case ${opt_name} in
+ music-driver)
+ opts='fluidsynth mt32 eas null mac towns pc98 segacd adlib core riscos camd sndio seq coremidi stmidi dmedia alsa timidity windows'
+ ;;
+ render-mode)
+ opts='hercGreen hercAmber cga cgaComp cgaBW ega vga amiga fmtowns pc98-256c pc98-16c pc98-8c 2gs atari macintosh macintoshbw cpc zx c64 vgaGrey win256c win16c'
+ ;;
+ esac
+
+ if [[ -n ${opts} ]]; then
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+ fi
+} &&
+ complete -F _scummvm scummvm
More information about the Scummvm-git-logs
mailing list