diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | assets/qtmaildir.bash-completion | 26 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 4 |
3 files changed, 33 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a9879a..830c09e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ point at which they are stable. `--message` accepts a Message-ID with or without its angle brackets. A selector that matches nothing is named in the status bar and the window keeps the view it had. +- Bash completion for the options, completing account keys from the config + after `--account`. Thread and message ids are not completed, since that + would query the whole index on every Tab. - A second launch now hands its selectors to the already-running window over a local socket and asks it to raise itself, rather than opening a second window. One process, and so one notmuch database handle. diff --git a/assets/qtmaildir.bash-completion b/assets/qtmaildir.bash-completion new file mode 100644 index 0000000..a203be8 --- /dev/null +++ b/assets/qtmaildir.bash-completion @@ -0,0 +1,26 @@ +# bash completion for qtmaildir +# +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# Licensed under the GNU General Public License version 2. +# +# Completes the options, and account keys after --account, read from the +# [account.<key>] sections of the config. Thread and message ids are NOT +# completed: listing them means querying the whole notmuch index on every Tab. + +_qtmaildir() +{ + local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} + local conf=${XDG_CONFIG_HOME:-$HOME/.config}/qtmaildir/qtmaildir.conf + + case $prev in + --account) + [[ -r $conf ]] || return + COMPREPLY=($(compgen -W "$(sed -n 's/^\[account\.\(.*\)\][[:space:]]*$/\1/p' "$conf")" -- "$cur")) + return ;; + --thread|--message) + return ;; + esac + + COMPREPLY=($(compgen -W '--account --thread --message --help --version' -- "$cur")) +} +complete -F _qtmaildir qtmaildir diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a344d5..5d41342 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -113,3 +113,7 @@ install(FILES ${CMAKE_SOURCE_DIR}/assets/icons/qtmaildir.svg DESTINATION share/icons/hicolor/scalable/apps) install(FILES ${CMAKE_SOURCE_DIR}/assets/qtmaildir.desktop DESTINATION share/applications) +# bash-completion loads a command's file on demand from this directory, by name. +install(FILES ${CMAKE_SOURCE_DIR}/assets/qtmaildir.bash-completion + DESTINATION share/bash-completion/completions + RENAME qtmaildir) |
