mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 14:29:16 +08:00
Read into local variables in some completions
Otherwise these might modify global or universal vars.
This commit is contained in:
parent
bb458c7186
commit
fe6c76d058
|
@ -111,7 +111,7 @@ end
|
|||
|
||||
function __fish_busctl_signature -a busname -a object -a interface -a member
|
||||
__fish_busctl introspect --list $busname $object $interface \
|
||||
| string match ".$member *" | while read a b c d
|
||||
| string match ".$member *" | while read -l a b c d
|
||||
echo $c
|
||||
end
|
||||
end
|
||||
|
|
|
@ -176,7 +176,7 @@ function __fish_ip_commandwords
|
|||
end
|
||||
|
||||
function __fish_ip_device
|
||||
ip -o link show | while read a b c
|
||||
ip -o link show | while read -l a b c
|
||||
printf '%s\t%s\n' (string replace ':' '' -- $b) Device
|
||||
end
|
||||
end
|
||||
|
@ -195,7 +195,7 @@ function __fish_ip_scope
|
|||
end
|
||||
|
||||
function __fish_ip_netns_list
|
||||
ip netns list | while read a b c
|
||||
ip netns list | while read -l a b c
|
||||
echo -- $a
|
||||
end
|
||||
end
|
||||
|
@ -264,7 +264,7 @@ function __fish_complete_ip
|
|||
case delete
|
||||
switch $count
|
||||
case 3
|
||||
ip -o addr show | while read a b c d e
|
||||
ip -o addr show | while read -l a b c d e
|
||||
echo $d
|
||||
end
|
||||
case 4
|
||||
|
@ -276,7 +276,7 @@ function __fish_complete_ip
|
|||
case 5
|
||||
switch $cmd[-2]
|
||||
case dev
|
||||
ip -o addr show | string match "*$cmd[3]*" | while read a b c
|
||||
ip -o addr show | string match "*$cmd[3]*" | while read -l a b c
|
||||
echo $b
|
||||
end
|
||||
# TODO: Moar
|
||||
|
|
|
@ -29,7 +29,7 @@ function __fish_iptables_user_chains
|
|||
set tablearg "--table=$table"
|
||||
end
|
||||
# This only works as root, so ignore errors
|
||||
iptables $tablearg -L 2>/dev/null | string match '*Chain*' | while read a b c
|
||||
iptables $tablearg -L 2>/dev/null | string match '*Chain*' | while read -l a b c
|
||||
echo $b
|
||||
end
|
||||
end
|
||||
|
@ -78,7 +78,7 @@ end
|
|||
|
||||
function __fish_iptables_has_chain
|
||||
# Remove descriptions
|
||||
set -l chains (__fish_iptables_chains | string split -m1 " " | while read a b; echo $a; end)
|
||||
set -l chains (__fish_iptables_chains | string split -m1 " " | while read -l a b; echo $a; end)
|
||||
set -l cmdline (commandline -op)
|
||||
for c in $chains
|
||||
if contains -- $c $cmdline
|
||||
|
|
|
@ -6,7 +6,7 @@ set -l iw_commands dev phy reg event features commands list
|
|||
# wdev not supported since it is barely documented
|
||||
|
||||
function __fish_iw_device
|
||||
__fish_print_interfaces | while read i
|
||||
__fish_print_interfaces | while read -l i
|
||||
printf '%s\t%s\n' $i Device
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,9 +17,7 @@ end
|
|||
|
||||
function __fish_journalctl_field_values
|
||||
set -l token (commandline -t | string split -f1 =)
|
||||
command journalctl -F $token 2>/dev/null | while read value
|
||||
echo $token=$value
|
||||
end
|
||||
echo $token=(command journalctl -F $token 2>/dev/null)
|
||||
end
|
||||
|
||||
complete -c journalctl -n "not __fish_journalctl_is_field" -a '(__fish_journalctl_fields)' -d "Journal field" -f
|
||||
|
@ -34,18 +32,19 @@ complete -c journalctl -f -s a -l all -d 'Show all fields in full'
|
|||
complete -c journalctl -f -s f -l follow -d 'Show live tail of entries'
|
||||
complete -c journalctl -f -s n -l lines -d 'Controls the number of journal lines'
|
||||
complete -c journalctl -f -l no-tail -d 'Show all lines, even in follow mode'
|
||||
complete -c journalctl -f -s o -l output -d 'Controls the formatting' -xa '(printf %s\t\n (journalctl --output=help))'
|
||||
complete -c journalctl -f -s o -l output -d 'Controls the formatting' -xa '(printf %s\t\n (command journalctl --output=help))'
|
||||
complete -c journalctl -f -s q -l quiet -d 'Suppress warning about normal user'
|
||||
complete -c journalctl -f -s m -l merge -d 'Show entries interleaved from all journals'
|
||||
|
||||
# Boot number (0 for current, -X for the Xst to last boot) with time as description
|
||||
complete -c journalctl -f -s b -l this-boot -d 'Show data only from a certain boot' -a '(journalctl --list-boots --no-pager | while read a b c; echo -e "$a\\t$c"; end)'
|
||||
complete -c journalctl -f -l this-boot -d 'Show data only from the current boot'
|
||||
complete -c journalctl -f -s b -l boot -d 'Show data only from a certain boot' -xa '(command journalctl 2>/dev/null --list-boots --no-pager | while read -l a b c; echo -e "$a\\t$c"; end)'
|
||||
complete -c journalctl -f -s u -l unit -d 'Show data only of the specified unit' -xa "(__fish_systemctl_services)"
|
||||
complete -c journalctl -f -s p -l priority -d 'Filter by priority' -xa 'emerg 0 alert 1 crit 2 err 3 warning 4 notice 5 info 6 debug 7'
|
||||
complete -c journalctl -f -s c -l cursor -d 'Start from the passing cursor'
|
||||
complete -c journalctl -f -l since -d 'Entries on or newer than DATE' -xa 'yesterday today tomorrow now'
|
||||
complete -c journalctl -f -l until -d 'Entries on or older than DATE' -xa 'yesterday today tomorrow now'
|
||||
complete -c journalctl -f -s F -l field -d 'Print all possible data values of FIELD' -xa '(printf %s\t\n (journalctl --fields))'
|
||||
complete -c journalctl -f -s F -l field -d 'Print all possible data values of FIELD' -xa '(printf %s\t\n (command journalctl --fields))'
|
||||
complete -c journalctl -f -s D -l directory -d 'Specify journal directory' -xa "(__fish_complete_directories)"
|
||||
complete -c journalctl -f -l new-id128 -d 'Generate a new 128 bit ID'
|
||||
complete -c journalctl -f -l header -d 'Show internal header information'
|
||||
|
@ -68,8 +67,8 @@ complete -c journalctl -f -l relinquish-var -d "Write to /run/log/journal/ inste
|
|||
complete -c journalctl -f -l smart-relinquish-var -d "Similar to --relinquish-var"
|
||||
complete -c journalctl -f -l rotate -d "Mark active journal files as archived and create new empty ones"
|
||||
complete -c journalctl -f -l output-fields -d "List of fields to be included in the output"
|
||||
complete -c journalctl -f -s t -l identifier -d "Show messages for specified syslog identifier" -xa '(printf %s\t\n (journalctl -F SYSLOG_IDENTIFIER))'
|
||||
complete -c journalctl -f -l user-unit -d "Show messages for the specified user session unit" -xa '(printf %s\t\n (journalctl -F _SYSTEMD_USER_UNIT))'
|
||||
complete -c journalctl -f -s t -l identifier -d "Show messages for specified syslog identifier" -xa '(printf %s\t\n (command journalctl -F SYSLOG_IDENTIFIER))'
|
||||
complete -c journalctl -f -l user-unit -d "Show messages for the specified user session unit" -xa '(printf %s\t\n (command journalctl -F _SYSTEMD_USER_UNIT))'
|
||||
complete -c journalctl -f -l facility -d "Filter output by syslog facility"
|
||||
complete -c journalctl -f -s g -l grep -d "Show entries where MESSAGE field matches regex"
|
||||
complete -c journalctl -f -l case-sensitive -d "Toggle pattern matching case sensitivity"
|
||||
|
|
|
@ -38,7 +38,7 @@ end
|
|||
function __fish_pa_complete_unloaded_modules
|
||||
# We need to get just the module names
|
||||
set -l loaded (__fish_pa_print_type modules | string replace -r '^\w*\t([-\w]+).*' '$1')
|
||||
pulseaudio --dump-modules | while read name description
|
||||
pulseaudio --dump-modules | while read -l name description
|
||||
# This is a potential source of slowness, but on my system it's instantaneous
|
||||
# with 73 modules
|
||||
if not contains -- $name $loaded
|
||||
|
|
|
@ -5,7 +5,7 @@ __fish_complete_wireshark tshark
|
|||
function __fish_tshark_protocols
|
||||
set -l tok (commandline -ct | string collect)
|
||||
set -l tok_param (string replace -r -- '^-O' '' $tok)
|
||||
command tshark -G protocols | while read -d \t name shortname identifier
|
||||
command tshark -G protocols | while read -l -d \t name shortname identifier
|
||||
printf "%s%s\t%s\n" (string replace -r -- '(.+),[^,]*$' '$1,' $tok_param) $tok_no_comma $identifier $name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ end
|
|||
|
||||
function __fish_print_xrandr_modes --description 'Print xrandr modes'
|
||||
set -l output
|
||||
xrandr | string match -v -r '^(Screen|\s{4,})' | while read line
|
||||
xrandr | string match -v -r '^(Screen|\s{4,})' | while read -l line
|
||||
switch $line
|
||||
case ' *'
|
||||
string trim $line | string replace -r '^(\S+)\s+(.*)$' "\$1\t\$2 [$output]"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_complete_gpg_command
|
||||
# Use user id as description
|
||||
set -l keyid
|
||||
$__fish_complete_gpg_command --list-keys --with-colons | while read garbage
|
||||
$__fish_complete_gpg_command --list-keys --with-colons | while read -l garbage
|
||||
switch $garbage
|
||||
case "uid*"
|
||||
# Extract user ids (note: gpg escapes colons as '\x3a')
|
||||
|
|
Loading…
Reference in New Issue
Block a user