From 61fe8d10a8e15285e2ad152017403e8bb609614b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 4 Feb 2013 17:24:47 +0200 Subject: ip: Improve addr show and link show completions. --- completions/ip | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/completions/ip b/completions/ip index e9e60d73..b073c36f 100644 --- a/completions/ip +++ b/completions/ip @@ -1,5 +1,12 @@ # ip(8) completion -*- shell-script -*- +_iproute2_etc() +{ + COMPREPLY+=( $( compgen -W \ + "$( awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null )" \ + -- "$cur" ) ) +} + _ip() { local cur prev words cword @@ -96,7 +103,14 @@ _ip() fi ;; show) - [[ $cword -eq $subcword+1 ]] && _available_interfaces + if [[ $cword -eq $subcword+1 ]]; then + _available_interfaces + COMPREPLY+=( $( compgen -W 'dev group up' -- "$cur" ) ) + elif [[ $prev == dev ]]; then + _available_interfaces + elif [[ $prev == group ]]; then + _iproute2_etc group + fi ;; *) [[ $cword -eq $subcword ]] && \ @@ -115,7 +129,16 @@ _ip() # TODO ;; show|flush) - # TODO + if [[ $cword -eq $subcword+1 ]]; then + _available_interfaces + COMPREPLY+=( $( compgen -W 'dev scope to label dynamic + permanent tentative deprecated dadfailed temporary + primary secondary up' -- "$cur" ) ) + elif [[ $prev == dev ]]; then + _available_interfaces + elif [[ $prev == scope ]]; then + _iproute2_etc rt_scopes + fi ;; *) [[ $cword -eq $subcword ]] && \ -- cgit v1.2.1