mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
completion/completions: use string match to detect usbip remote
* completion/usbip: use string-match to detect remote (#9250) * simplify output Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com> Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
This commit is contained in:
parent
40a0ea9bea
commit
794926d28e
1 changed files with 7 additions and 16 deletions
|
@ -9,27 +9,18 @@ end
|
||||||
|
|
||||||
function __fish_usbip_remote -d 'List remote usbip host'
|
function __fish_usbip_remote -d 'List remote usbip host'
|
||||||
set -l remote (ip r | awk '/via/ {print $3"\t"$5}')
|
set -l remote (ip r | awk '/via/ {print $3"\t"$5}')
|
||||||
for i in $remote
|
printf '%s\n' $remote
|
||||||
echo $i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_usbip_busid -d 'List usbip busid'
|
function __fish_usbip_busid -d 'List usbip busid'
|
||||||
set -l token (commandline -opc)
|
set -l remote (commandline -opc | string match -r '([0-9]{1,3}\.){3}[0-9]{1,3}')
|
||||||
if contains -- -r $token
|
set -l busids (usbip list -r $remote 2> /dev/null | string match -r '\d+-\d+')
|
||||||
set -l remote (commandline -opc | string match -r '([0-9]{1,3}\.){3}[0-9]{1,3}')
|
printf '%s\n' $busids
|
||||||
set -l busids (usbip list -r $remote 2> /dev/null | string match -r '\d+-\d+')
|
|
||||||
for i in $busids
|
|
||||||
echo $i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_usbip_busid_attached -d 'List usbip busid attached'
|
function __fish_usbip_busid_attached -d 'List usbip busid attached'
|
||||||
set -l usbids (usbip port 2> /dev/null | string match -r '(?<=Port\s)(\d+)')
|
set -l usbids (usbip port 2> /dev/null | string match -r '(?<=Port\s)(\d+)')
|
||||||
for i in $usbids
|
printf '%s\n' $usbids
|
||||||
echo $i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
complete -f -c usbip
|
complete -f -c usbip
|
||||||
|
|
Loading…
Reference in a new issue