Skip to content

Commit

Permalink
Fix completion script to avoid unwanted index updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Mar 20, 2024
1 parent 86f4124 commit bf6a5f8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/alr-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ if ! builtin type -P alr &>/dev/null; then
return
fi

# Disable index auto-update to avoid interference with commands below
if alr settings --global | grep -q index.auto_update= ; then
update_period=$(alr settings --global | grep index.auto_update= | cut -f2 -d=)
else
update_period=unset
fi
alr settings --global --set index.auto_update 0

# Commands/Topics: all line-first words not starting with capital letter, after # COMMANDS
_alr_commands=$(alr | grep COMMANDS -A 99 | awk '{print $1}' | grep -v '[[:upper:]]' | xargs)

Expand Down Expand Up @@ -80,3 +88,8 @@ function _alr_completion() {

# Bind the function that performs context-aware completion
complete -F _alr_completion alr

# Re-enable index auto-update to avoid interference with commands below
if [ "$update_period" != "unset" ]; then
alr settings --global --set index.auto_update $update_period
fi

0 comments on commit bf6a5f8

Please sign in to comment.