Skip to content

Add bash autocompletion support for utimer#8

Merged
sarsolot merged 10 commits intomasterfrom
feature/autocompletion-issue-5
Aug 30, 2025
Merged

Add bash autocompletion support for utimer#8
sarsolot merged 10 commits intomasterfrom
feature/autocompletion-issue-5

Conversation

@sarsolot
Copy link
Owner

Add bash autocompletion support for utimer

Summary

Implements bash tab-completion for utimer command-line interface, addressing issue #5.

Features Added

  • Complete option support: All long options (--timer, --countdown, --stopwatch, --clock, --verbose, --quiet, --quit-with-success, --limits, --version, --help, --debug)
  • Short option support: All short options (-t, -c, -s, -k, -v, -q, -L, -d, -h)
  • Smart time pattern suggestions: After --timer and --countdown options, suggests common patterns (1s, 5s, 10s, 30s, 1m, 2m, 5m, 10m, 30m, 1h, 2h)
  • Cross-platform installation: Supports both modern (/usr/share/bash-completion/completions/) and legacy (/etc/bash_completion.d/) paths

Implementation Details

  • Auto-detection: Uses pkg-config to detect system bash-completion directory
  • Proper naming: Installs completion script as utimer (matching command name) for auto-loading
  • Autotools integration: Seamlessly integrated into existing build system
  • Conditional compilation: Only builds/installs if bash-completion is available

Testing

  • Manually tested tab completion for all options
  • Verified time pattern suggestions work correctly
  • Confirmed installation path detection works on modern systems
  • Tested both partial and full option completion

Files Changed

  • configure.ac: Added bash-completion detection via PKG_CHECK_MODULES
  • Makefile.am: Added completion subdirectory to build
  • completion/Makefile.am: Installation logic for completion script
  • completion/utimer-completion.bash: The bash completion implementation

Usage Example

After installation:

utimer --c<TAB>     # Completes to --countdown or --clock
utimer --timer 5<TAB> # Suggests 5s, 5m
utimer -<TAB>       # Shows all short and long options

Fixes #5

- Add bash completion script with support for all CLI options
- Complete long options (--timer, --countdown, --stopwatch, --clock, etc.)
- Complete short options (-t, -c, -s, -k, etc.)
- Suggest common time patterns for timer/countdown options
- Integrate completion into autotools build system
- Add PKG_CHECK_MODULES for bash-completion detection
- Install completion script as 'utimer' for proper auto-loading
- Support both modern (/usr/share/bash-completion/completions/) and
  legacy (/etc/bash_completion.d/) installation paths

Fixes #5
Document bash completion support added in this PR (#5)
… suggestions

- Add --milliseconds/-m to available options list
- Improve completion logic to suggest -m after --clock is used
- Ensure completion script works with both autocompletion and clock features
- Fixes make check failure in completion directory
- Adds compatibility with Makefile.decl test target requirement
- All tests still pass (9/9), now CI build completes successfully
@sarsolot sarsolot merged commit 072701d into master Aug 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command autocompletion

1 participant