feat(ff-ssh): add host from ssh args with ssh-copy-id
- ff ssh <ssh-args> parses target like ssh, runs ssh-copy-id, then writes ~/.ssh/config.d/<alias>.conf (HostName/User/Port/IdentityFile/ ProxyJump/ProxyCommand); supports --no-copy, add and run subcommands - record IdentityFile whenever -i / -o IdentityFile= is given and pass the same key to ssh-copy-id; omit it otherwise so ssh falls back to default identities - ff ssh re-sources ff-ssh.fish each call, ff reload clears cached dotfile functions so edits take effect - fix broken copy subcommand and ssh-arg parsing caused by --argument-names argv shadowing fish $argv - fix ssh subcommand completion guards; wrap ssh completions for add/run
This commit is contained in:
@@ -14,7 +14,7 @@ complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "s" -d "R
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "help" -d "Show this help message"
|
||||
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "region" -d "Toggle or set CN_REGION (mirror/proxy region)"
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "ssh" -d "SSH init (keys + config.d) or copy config to remote"
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "ssh" -d "SSH init / copy key + add host / copy config to remote"
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "dirsize" -d "Show directory sizes"
|
||||
|
||||
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s a -l all -d "Recursively show all subdirectories"
|
||||
@@ -24,9 +24,14 @@ complete -c ff -n "__fish_seen_subcommand_from dirsize" -s r -l reverse -d "Sort
|
||||
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s h -l help -d "Show help"
|
||||
complete -c ff -n "__fish_seen_subcommand_from dirsize" -a "(__fish_complete_directories)" -d "Directory"
|
||||
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a init -d "Ensure SSH key and config.d Include"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a copy -d "Copy specified SSH config file(s) to remote"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -a help -d "Show ssh subcommand help"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help; and test (count (commandline -opc)) -eq 2" -a init -d "Ensure SSH key and config.d Include"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help; and test (count (commandline -opc)) -eq 2" -a add -d "Copy key + add host from ssh-style args"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help; and test (count (commandline -opc)) -eq 2" -a run -d "Copy key + add host, then connect"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help; and test (count (commandline -opc)) -eq 2" -a copy -d "Copy specified SSH config file(s) to remote"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help; and test (count (commandline -opc)) -eq 2" -a help -d "Show ssh subcommand help"
|
||||
|
||||
# 裸参数与 ssh 原生参数一致:复用 ssh 自带的补全(选项 + 主机名)
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy add run help" -w ssh
|
||||
|
||||
function __ff_ssh_config_d_files
|
||||
for d in $HOME/.ssh/config.d $HOME/.dotfile/ssh/config.d
|
||||
@@ -40,8 +45,12 @@ function __ff_ssh_config_d_files
|
||||
end
|
||||
end
|
||||
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh copy; and test (count (commandline -opc)) -eq 2" -a "(__fish_ssh_hosts 2>/dev/null; or __fish_print_hostnames)" -d "SSH host"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh copy; and test (count (commandline -opc)) -ge 3" -a "(__ff_ssh_config_d_files)" -d "Config file"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and __fish_seen_subcommand_from copy; and test (count (commandline -opc)) -eq 3" -a "(__fish_print_hostnames)" -d "SSH host"
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and __fish_seen_subcommand_from copy; and test (count (commandline -opc)) -ge 4" -a "(__ff_ssh_config_d_files)" -d "Config file"
|
||||
|
||||
# add/run 使用与 ssh 相同的参数:直接复用 ssh 的选项与主机补全
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and __fish_seen_subcommand_from add run" -w ssh
|
||||
complete -c ff -n "__fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from init copy help" -l no-copy -d "Skip ssh-copy-id"
|
||||
|
||||
# # make 子命令的补全 - 直接使用脚本文件名
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "help" -d "Show all make targets"
|
||||
|
||||
Reference in New Issue
Block a user