mabox-pipemenus/usr/bin/jgssh
2021-05-23 10:20:13 +02:00

80 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Daniel Napora 2021 <napcok@gmail.com>
#: jgssh - pipemenu for connecting to hosts defined in ~/.ssh/config
#: Usage: jgssh ( )
#:
#:
case $LANG in
pl*)
SSH_CONN="Połączenia SSH"
CONNECT="Połącz z"
TERM="Terminal"
FM="Menadżer plików"
REMOVE="Usuń to menu z panelu"
EDIT="Edytuj"
;;
es*)
SSH_CONN="Hosts SSH"
CONNECT="Conectar a"
TERM="Terminal"
FM="Gestor de archivos"
REMOVE="Eliminar este menú del panel"
EDIT="Editar"
;;
*)
SSH_CONN="SSH hosts"
CONNECT="Connect to"
TERM="Terminal"
FM="File Manager"
REMOVE="Remove this menu from panel"
EDIT="Edit"
;;
esac
__usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
__mklist() {
hostlist=$(sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\{1,\}\([^#*?%]*\)\(#.*\)\{0,1\}$/\1/p' ~/.ssh/config)
out+=("^sep($SSH_CONN)")
for host in $hostlist;
do
out+=("$host,^checkout($host)")
out2+=("^tag($host)")
out2+=("^sep($CONNECT $host)")
out2+=("<big></big> $TERM,^term(ssh $host)")
out2+=("$FM,pcmanfm $HOME sftp://$host/")
done
out+=("^sep()")
out+=("$EDIT <i>~/.ssh/config</i>, geany $HOME/.ssh/config")
}
__removable() {
__mklist
out+=("^sep()")
out+=("<i>$REMOVE</i>,mb-setvar places_sshpipe=false;mb-jgtools places")
__ret
}
__standalone() {
echo "TODO"
}
__ret() {
printf '%s\n' "${out[@]}"
printf '%s\n' "${out2[@]}"
}
case "$1" in
"-r") __removable ;;
"-s") __standalone ;;
"-h"|"--help") __usage ;;
*) __usage ;;
esac
exit 0