Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: device cannot be completed after "ip link show dev"



On Mar 30,  9:27pm, Eric Cook wrote:
}
} I can't seem to find a pattern that works in both cases, but adding the
} previous line back allows completing after: `ip link show dev'.
} But after the argument for `dev', the option `up' is no longer show.
} 
} Hopefully someone with better knowledge of the _regex_* functions could
} help.

I don't really know _regex_* "better" -- in fact I've barely looked at it
before -- but based on the "either aaa or bbb" example in the doc, what
about this?


diff --git a/Completion/Unix/Command/_ip b/Completion/Unix/Command/_ip
index 3b68c35..c0a28d3 100644
--- a/Completion/Unix/Command/_ip
+++ b/Completion/Unix/Command/_ip
@@ -9,7 +9,8 @@
 # Values encoding simple types
 #
 local -a subcmd_dev
-subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ ':interfaces:network interface:_net_interfaces')
+subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ ':interfaces:network interface:_net_interfaces' "|"
+  /$'dev\0'/ ':interfaces:network interface:_net_interfaces')
 
 local -a subcmd_onoff
 subcmd_onoff=(/$'(on|off)\0'/ ':onoff:state (on or off):(on off)')


I suspect there should be some way to use the "-GUARD" syntax to prevent
"dev" from completing again after "dev" ("ip link show dev dev" doesn't
make sense, does it?) but there's no example of using a guard, and as
someone implied, offering too much (as long as it's not *TOO* much) is
better than offering too little.



Messages sorted by: Reverse Date, Date, Thread, Author