33 lines
1.8 KiB
Bash
33 lines
1.8 KiB
Bash
# Completion, aliases, hook install for bash, zsh, fish, and the command alias.
|
|
config <<'EOF'
|
|
resolver:
|
|
strategies: [management_subnet, primary_ip]
|
|
management_subnets: [10.231.1.0/24]
|
|
ssh:
|
|
default_user: ops
|
|
forwards:
|
|
web: {local: "18081:127.0.0.1:8081"}
|
|
shortcuts:
|
|
domains: [.hoster.test]
|
|
shell:
|
|
alias: j
|
|
EOF
|
|
check "refresh" netssh cache refresh
|
|
expect_out "complete hosts" "fsn/fsn1-pve2.hoster.test" netssh __complete fsn/fsn1
|
|
expect_out "complete scp host:" "fsn/fsn1-pve1.hoster.test:" netssh __complete scp a.txt fsn/fsn1-pve1
|
|
expect_out "complete forwards after the host" "web" netssh __complete tunnel fsn/fsn1-pve1.hoster.test ""
|
|
expect_out "complete --forward" "web" netssh __complete --forward ""
|
|
expect_out "fish aliases" "alias fsn_fsn1-pve1 " netssh alias --shell fish
|
|
|
|
check "hook install bash" netssh hook install --shell bash
|
|
# Interactive bash without a terminal warns about job control on stderr.
|
|
expect_eq "bash loads host aliases" "fsn1-pve1" sh -c "bash -ic 'fsn_fsn1-pve1 hostname' 2>/dev/null </dev/null"
|
|
expect_eq "bash command alias" "fsn1-pve2" sh -c "bash -ic 'j fsn/fsn1-pve2.hoster.test hostname' 2>/dev/null </dev/null"
|
|
check "hook install zsh" netssh hook install --shell zsh
|
|
expect_eq "zsh loads host aliases" "fsn1-pve3" zsh -ic 'fsn_fsn1-pve3 hostname' </dev/null
|
|
mkdir -p "$XDG_CONFIG_HOME/fish"
|
|
check "hook install fish" netssh hook install --shell fish
|
|
expect_eq "fish loads host aliases" "fsn1-pve1" fish -c 'fsn_fsn1-pve1 hostname' </dev/null
|
|
check "completion install bash" netssh completion install --shell bash
|
|
expect_out "bash completes hosts" "fsn/fsn1-pve2.hoster.test" bash -ic '. ~/.local/share/bash-completion/completions/netssh; COMP_WORDS=(netssh fsn/fsn1-pve2); COMP_CWORD=1; COMP_LINE="netssh fsn/fsn1-pve2"; COMP_POINT=${#COMP_LINE}; __start_netssh netssh; printf "%s\n" "${COMPREPLY[@]}"' </dev/null
|