mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
machinectl: Add "shell" subcommand
This commit is contained in:
parent
3992315505
commit
126c8c14b8
@ -2,7 +2,7 @@ complete -f -e -c machinectl
|
||||
|
||||
set -l commands list status show start login enable disable poweroff reboot \
|
||||
terminate kill bind copy-{to,from} list-images image-status show-image clone rename read-only remove set-limit pull-{tar,raw,dkr} \
|
||||
{import,export}-{raw,tar} {list,cancel}-transfers
|
||||
{import,export}-{raw,tar} {list,cancel}-transfers shell
|
||||
|
||||
function __fish_systemd_has_machine_image
|
||||
set -l images (__fish_systemd_machine_images)
|
||||
@ -17,9 +17,15 @@ function __fish_systemd_has_machine_image
|
||||
end
|
||||
|
||||
function __fish_systemd_has_machine
|
||||
set -l cmd
|
||||
if not count $argv >/dev/null
|
||||
set cmd (commandline -opc)
|
||||
else
|
||||
set cmd $argv
|
||||
end
|
||||
set -l machines (__fish_systemd_machines)
|
||||
for m in $machines
|
||||
if contains -- $m (commandline -opc)
|
||||
if contains -- $m $cmd
|
||||
echo $m
|
||||
return 0
|
||||
end
|
||||
@ -71,6 +77,8 @@ complete -f -c machinectl -n "__fish_seen_subcommand_from bind" -l read-only -d
|
||||
complete -f -c machinectl -n "not __fish_seen_subcommand_from $commands" -a "copy-to" -d "Copy file or directory to a machine"
|
||||
complete -f -c machinectl -n "not __fish_seen_subcommand_from $commands" -a "copy-from" -d "Copy file or directory from a machine"
|
||||
|
||||
complete -f -c machinectl -n "not __fish_seen_subcommand_from $commands" -a "shell" -d "Open a shell on a machine"
|
||||
|
||||
# Image commands
|
||||
complete -f -c machinectl -n "not __fish_seen_subcommand_from $commands" -a "list-images" -d "Show a list of locally installed machines"
|
||||
complete -f -c machinectl -n "not __fish_seen_subcommand_from $commands" -a "image-status" -d "Show information about machine images (human-readable)"
|
||||
@ -110,5 +118,9 @@ complete -f -c machinectl -n "__fish_seen_subcommand_from start clone rename ima
|
||||
# while login takes exactly one machine and nothing else, which fish currently doesn't do
|
||||
complete -f -c machinectl -n "__fish_seen_subcommand_from login bind copy-to copy-from; and not __fish_systemd_has_machine" -a "(__fish_systemd_machines)"
|
||||
|
||||
complete -f -c machinectl -n "__fish_seen_subcommand_from login bind copy-to copy-from shell; and not __fish_systemd_has_machine" -a "(__fish_systemd_machines)"
|
||||
# This is imperfect as we print the _local_ users
|
||||
complete -f -c machinectl -n "__fish_seen_subcommand_from shell; and not __fish_systemd_has_machine (commandline -opc | cut -d"@" -f2-)" -a "(__fish_print_users)@(__fish_systemd_machines)"
|
||||
|
||||
complete -f -c machinectl -n "__fish_seen_subcommand_from read-only; and not __fish_systemd_has_machine_image" -a "(__fish_systemd_machine_images)"
|
||||
complete -f -c machinectl -n "__fish_seen_subcommand_from read-only; and __fish_systemd_has_machine_image" -a "yes no"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# It seems machinectl will eliminate spaces from machine names so we don't need to handle that
|
||||
function __fish_systemd_machines
|
||||
machinectl --no-legend --no-pager list | while read -l a b; echo $a; end
|
||||
machinectl --no-legend --no-pager list --all | while read -l a b; echo $a; end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user