summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-08-09 21:25:47 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-08-09 21:25:47 +0200
commit6f722a59cc2f0c00deaf022f0835455207de3ca5 (patch)
treea7a4107683d7f08cda81d77c738dc73a80f1ac19
parent07239de1b7b918b9c8aa664b5eae3fddfa357f5e (diff)
bash: Add auto-cpufreq completions
-rw-r--r--.bashrc37
1 files changed, 37 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
index 8ca461a..6b3db5a 100644
--- a/.bashrc
+++ b/.bashrc
@@ -102,4 +102,41 @@ alias v="$VISUAL"
PS1='\[\e[96;1m\]\u \[\e[39m\]\W \[\e[96m\]〉\[\e[0m\]'
+# Autocompletions for auto-cpufreq. Inlined from the generated output
+# for performance reasons.
+_auto_cpufreq_completion() {
+ local IFS=$'\n'
+ local response
+
+ response=$(
+ env \
+ COMP_WORDS="${COMP_WORDS[*]}" \
+ COMP_CWORD=$COMP_CWORD \
+ _AUTO_CPUFREQ_COMPLETE=bash_complete \
+ $1
+ )
+
+ for completion in $response; do
+ IFS=',' read type value <<<"$completion"
+
+ case $type in
+ dir)
+ COMPREPLY=()
+ compopt -o dirnames
+ ;;
+ file)
+ COMPREPLY=()
+ compopt -o default
+ ;;
+ plain)
+ COMPREPLY+=($value)
+ ;;
+ esac
+ done
+
+ return 0
+}
+
+complete -o nosort -F _auto_cpufreq_completion auto-cpufreq
+
# sed '1s/^/‘/; $s/$/’/' "$XDG_CACHE_HOME/qotd" | fold -sw 80