4127 links
739 private links
  • Doo's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
  • ► Jouer les vidéos
Links per page: 20 50 100
  • bash_completion/nft-completion at main · Zulugitt/bash_completion
    _nft()
    {
        local cur prev
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    
        local families="ip ip6 arp bridge inet netdev"
        local sets=$(nft list sets | grep -i "set" | awk '{print $2 }' | tr -d ' ')
    
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=( $(compgen -W "add flush list" -- $cur) )
        elif [ $COMP_CWORD -eq 2 ]; then
            case "$prev" in
                "add")
                    command="${prev}"
                    COMPREPLY=( $(compgen -W "element map table set" -- $cur) )
                    ;;
                "list")
                    COMPREPLY=( $(compgen -W "chains ruleset set sets table tables" -- $cur) )
                    ;;
                "flush")
                    COMPREPLY=( $(compgen -W "table" -- $cur) )
                    ;;
                *)
                    ;;
            esac
        elif [ $COMP_CWORD -eq 3 ]; then
            case "$prev" in
                "table")
                    COMPREPLY=( $(compgen -W "${families}" -- $cur) )
                    ;;
                "set"|"element"|"map")
                    local tables=$(nft list tables | awk '{print $3 }' | tr -d ' ')
                    COMPREPLY=( $(compgen -W "${tables}" -- $cur) )
                    ;;
                *)
                    ;;
            esac
        elif [ $COMP_CWORD -eq 4 ]; then
            local tables=$(nft list tables | awk '{print $3 }' | tr -d ' ')
            if [[ "$families" =~ "$prev" ]]; then
                local tables=$(nft list tables "${prev}" | awk '{print $3 }' | tr -d ' ')
                COMPREPLY=( $(compgen -W "${tables}" -- $cur) )
            fi
    
            if [ "${COMP_WORDS[1]}" != "add" ] && [[ "$tables" =~ "$prev" ]]; then
                COMPREPLY=( $(compgen -W "${sets}" -- $cur) )
            fi
    
            if [ "${COMP_WORDS[1]}" == "add" ] && [ "${COMP_WORDS[2]}" == "element" ] && [[ "$tables" =~ "$prev" ]]; then
                COMPREPLY=( $(compgen -W "${sets}" -- $cur) )
            fi
        fi
    
        return 0;
    }
    
    complete -F _nft nft
    January 7, 2025 02:42:01 PM GMT+01:00 * - permalink -
    QRCode
    - https://github.com/Zulugitt/bash_completion/blob/main/nft-completion
    nftables
Links per page: 20 50 100
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation