Skip to content

Commit

Permalink
feat(_ip_addresses): auto ltrim colon completions when appropriate
Browse files Browse the repository at this point in the history
Initializing the completion with `-n :` is still needed.
  • Loading branch information
scop committed May 26, 2023
1 parent 5d57dd0 commit ccdf953
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,8 @@ _configured_interfaces()
}

# Local IP addresses.
# If producing IPv6 completions, use `-n :' to `_comp_initialize`.
#
# -4: IPv4 addresses only (default)
# -6: IPv6 addresses only
# -a: All addresses
Expand All @@ -1526,6 +1528,7 @@ _ip_addresses()
command sed -e 's/[[:space:]]addr:/ /' -ne \
"s|.*inet${n}[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p")
_comp_compgen -a -- -W "$addrs"
[[ ! $n ]] || _comp_ltrim_colon_completions "$cur"
}

# This function completes on available kernels
Expand Down
1 change: 0 additions & 1 deletion completions/iperf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ _comp_cmd_iperf()
--bind | -${noargopts}B)
_available_interfaces -a
_ip_addresses -a
_comp_ltrim_colon_completions "$cur"
return
;;
--bind-dev)
Expand Down
1 change: 0 additions & 1 deletion completions/links
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ _comp_cmd_links()
;;
-bind-address-ipv6)
_ip_addresses -6
_comp_ltrim_colon_completions "$cur"
return
;;
-async-dns | -download-utime | -aggressive-cache | -only-proxies | \
Expand Down
1 change: 0 additions & 1 deletion completions/nc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ _comp_cmd_nc()
-*s)
if [[ ${words[*]} == *-6* ]]; then
_ip_addresses -6
_comp_ltrim_colon_completions "$cur"
else
_ip_addresses
fi
Expand Down

0 comments on commit ccdf953

Please sign in to comment.