bash-completions
Instructions for adding to bash auto completions in the AutomateLinux project.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Bash Auto-Completions
This project uses a modular system for bash auto-completions. Each major command has its own completion script located in ./terminal/completions/.
1. Create the Completion Script
Create a new .bash file in the ./terminal/completions/ directory.
Basic Template
_my_command_completion() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Define words to complete
local opts="start stop restart status"
if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _my_command_completion my_command
2. Register the Script
All completion scripts must be explicitly sourced in ./terminal/completions/completion.sh to be active in the terminal.
Add a line to source your new file:
# In ./terminal/completions/completion.sh
. $(theRealPath my_new_completion.bash)
[!NOTE] The
theRealPathutility ensures the script is sourced correctly regardless of the current working directory.
3. Apply Changes
To see your new completions in action, either open a new terminal or source your bashrc:
sb # Shorthand for sourcing ~/.bashrc
Existing Examples
For more complex logic (like handling sub-commands or dynamic arguments), refer to:
-
daemon.bash: Handles
danddaemoncommands. - cd.bash: Handles directory history navigation.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!