]> git.feebdaed.xyz Git - 0xmirror/pi-hole.git/commitdiff
Add pihole-FTL bash completion
authorChristian König <github@yubiuser.dev>
Wed, 6 Aug 2025 10:51:08 +0000 (12:51 +0200)
committerChristian König <github@yubiuser.dev>
Wed, 6 Aug 2025 11:05:36 +0000 (13:05 +0200)
Signed-off-by: Christian König <github@yubiuser.dev>
advanced/bash-completion/pihole-ftl.bash [new file with mode: 0644]
automated install/basic-install.sh
automated install/uninstall.sh

diff --git a/advanced/bash-completion/pihole-ftl.bash b/advanced/bash-completion/pihole-ftl.bash
new file mode 100644 (file)
index 0000000..f83ed16
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Bash completion script for pihole-FTL
+#
+# This completion script provides tab completion for some pihole-FTL CLI flags and commands.
+_pihole_ftl_completion() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    # Selected commands and flags
+    opts="version tag branch help dnsmasq-test regex-test lua sqlite3 --config --teleporter --gen-x509 --read-x509 gravity ntp gzip dhcp-discover arp-scan idn2 sha256sum verify --default-gateway"
+
+    # Handle subcommands for specific commands
+    case "${prev}" in
+        # Gravity subcommands
+        gravity)
+            mapfile -t COMPREPLY < <(compgen -W "checkList" -- "${cur}")
+            return 0
+            ;;
+
+        # SQLite3 special modes
+        sqlite3)
+            mapfile -t COMPREPLY < <(compgen -W "-h -ni" -- "${cur}")
+            return 0
+            ;;
+
+        # ARP scan options
+        arp-scan)
+            mapfile -t COMPREPLY < <(compgen -W "-a -x" -- "${cur}")
+            return 0
+            ;;
+
+        # IDN2 options
+        idn2)
+            mapfile -t COMPREPLY < <(compgen -W "--decode" -- "${cur}")
+            return 0
+            ;;
+
+        # NTP options
+        ntp)
+            mapfile -t COMPREPLY < <(compgen -W "--update" -- "${cur}")
+            return 0
+            ;;
+
+    esac
+    # Default completion
+    mapfile -t COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
+}
+
+# Register the completion function for pihole-FTL
+complete -F _pihole_ftl_completion pihole-FTL
index daacb9a3dc82b012829513b16ed27313d3adf273..4e823ec4cbfd6e7d50ea924a1e6faf4ad55fedbd 100755 (executable)
@@ -1138,6 +1138,7 @@ installScripts() {
         install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
         install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
         install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
+        install -Dm644 ./advanced/bash-completion/pihole-ftl.bash /etc/bash_completion.d/pihole-FTL
         printf "%b  %b %s\\n" "${OVER}" "${TICK}" "${str}"
 
     else
index e8dec36acc714f74fa5cb65c33f63cd25e23d69c..dfe0871e7291e63a9bebc9f8eef84e40f5ec3088 100755 (executable)
@@ -89,6 +89,7 @@ removePiholeFiles() {
     ${SUDO} rm -rf /opt/pihole/ &> /dev/null
     ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null
     ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null
+    ${SUDO} rm -f /etc/bash_completion.d/pihole-FTL &> /dev/null
     ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
     echo -e "  ${TICK} Removed config files"