Skip to content

Tab Autocompletion migrate to bash#178

Draft
ikifar2012 wants to merge 10 commits intohome-assistant:masterfrom
ikifar2012:bash-migration
Draft

Tab Autocompletion migrate to bash#178
ikifar2012 wants to merge 10 commits intohome-assistant:masterfrom
ikifar2012:bash-migration

Conversation

@ikifar2012
Copy link
Copy Markdown
Member

This is just a proof of concept I have been playing around with, this aims to add tab completion to make the experience feel a bit more polished. I feel tab completion is an absolute must when trying to debug at a physical console

@agners agners requested a review from sairon October 23, 2025 14:45
Copy link
Copy Markdown
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite some comments below but it's mostly about cleaning up the slop, in overall I like the change and in quick testing it works as intended.

Comment thread rootfs/etc/ha-cli/.repl_rc Outdated
Comment on lines +20 to +30
# Friendly helpers
help() {
echo 'Note: Use "login" to enter operating system shell'
echo ''
echo '--------------------------------'
ha help
}
login() {
echo 'Entering OS shell...'
exit 10;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some formatting issues here.

Comment thread rootfs/etc/ha-cli/.repl_rc Outdated
Comment thread rootfs/etc/ha-cli/.repl_rc Outdated
Comment thread rootfs/etc/ha-cli/.repl_rc Outdated

# Wrapper function to inject 'ha' as first argument for all completions
if declare -F __start_ha >/dev/null 2>&1; then
__start_ha >/dev/null 2>&1 || true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this line?

Comment thread rootfs/etc/ha-cli/.repl_rc Outdated

# Universal completion handler - wraps everything as 'ha ...'
__ha_repl_complete() {
local cur prev words cword
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables are not used anywhere.

Comment thread README.md
# CLI for the Home Assistant Operating System

This is for the Home Assistant Operating System and is the login shell.
This is for the Home Assistant Operating System and is the login shell. No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit; but looks like some newline issue after the revert, this change shouldn't be here.

Comment thread Dockerfile
build-base \
readline-dev \
ncurses-dev \
&& curl -L -s "https://github.com/hanslub42/rlwrap/releases/download/${RLWRAP_VERSION}/rlwrap-${RLWRAP_VERSION}.tar.gz" \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this makes RLWRAP_VERSION in the build.yaml obsolete.

Comment thread Dockerfile
&& rm -rf /usr/src/*
# Install dependencies
RUN apk add --no-cache \
bash-completion
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It provides some of the functions used by the completion script, I'll take another look but pretty sure its needed

Comment thread rootfs/usr/bin/cli.sh

# Run CLI
COMMAND=""
while true; do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously EOF (Ctrl+D) didn't exit this loop, while it does exit the REPL in the current implementation. We should also set set -o ignoreeof so only Ctrl+C exits it.

@home-assistant home-assistant bot marked this pull request as draft February 10, 2026 12:16
@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants