mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-25 10:23:42 +01:00
Add gumssh
This commit is contained in:
parent
83f24d5ff3
commit
227d478031
8
emacs
8
emacs
@ -1,8 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# distrobox_binary
|
|
||||||
# name: "default0"
|
|
||||||
if [ ! -f /run/.containerenv ] && [ ! -f /.dockerenv ]; then
|
|
||||||
/usr/local/bin/distrobox-enter -n "default0" -- /bin/emacs $@
|
|
||||||
else
|
|
||||||
/bin/emacs $@
|
|
||||||
fi
|
|
39
gumssh
Executable file
39
gumssh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Check for gum
|
||||||
|
if ! test -x "$(command -v gum)"; then
|
||||||
|
echo "Missing dependency: gum"
|
||||||
|
echo "See github.com/charmbracelet/gum"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SSH_CONFIG="${HOME}/.ssh/config"
|
||||||
|
usern_array=()
|
||||||
|
hostn_array=()
|
||||||
|
logins=()
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ "$line" == *"User"* ]]; then
|
||||||
|
usern=$(echo $line | awk '{ print $2 }')
|
||||||
|
usern_array+=($usern)
|
||||||
|
fi
|
||||||
|
done < "${SSH_CONFIG}"
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ "$line" == *"HostName"* ]]; then
|
||||||
|
hostn=$(echo $line | awk '{ print $2 }')
|
||||||
|
hostn_array+=($hostn)
|
||||||
|
fi
|
||||||
|
done < "${SSH_CONFIG}"
|
||||||
|
|
||||||
|
let "array_len = ${#usern_array[@]} - 1"
|
||||||
|
|
||||||
|
for i in $(seq 0 $array_len); do
|
||||||
|
userhost=$(printf "%s@%s" "${usern_array[i]}" "${hostn_array[i]}")
|
||||||
|
logins+=($userhost)
|
||||||
|
done
|
||||||
|
|
||||||
|
selection=$(printf "%s\n" "${logins[@]}" | gum choose --limit=1)
|
||||||
|
if test -n "${selection}"; then
|
||||||
|
ssh -X "${selection}"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user