3
This commit is contained in:
47
scripts/ssh-url
Executable file
47
scripts/ssh-url
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# ssh-url - Handler pour les URLs ssh://
|
||||
# Reçoit une URL ssh://user@host et ouvre un terminal avec la connexion SSH
|
||||
#
|
||||
|
||||
# URL reçue en argument (ex: ssh://gilles@10.0.0.24)
|
||||
URL="$1"
|
||||
|
||||
if [ -z "$URL" ]; then
|
||||
echo "Usage: $0 ssh://user@host"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extraire la partie user@host en supprimant le préfixe ssh://
|
||||
SSH_TARGET="${URL#ssh://}"
|
||||
|
||||
# Supprimer un éventuel / final
|
||||
SSH_TARGET="${SSH_TARGET%/}"
|
||||
|
||||
if [ -z "$SSH_TARGET" ]; then
|
||||
echo "Erreur: impossible d'extraire la cible SSH de l'URL: $URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Détecter le terminal disponible et lancer SSH
|
||||
# Liste des terminaux supportés (ordre de préférence)
|
||||
if command -v gnome-terminal &> /dev/null; then
|
||||
gnome-terminal -- ssh "$SSH_TARGET"
|
||||
elif command -v xfce4-terminal &> /dev/null; then
|
||||
xfce4-terminal -e "ssh $SSH_TARGET"
|
||||
elif command -v konsole &> /dev/null; then
|
||||
konsole -e ssh "$SSH_TARGET"
|
||||
elif command -v xterm &> /dev/null; then
|
||||
xterm -e ssh "$SSH_TARGET"
|
||||
elif command -v terminator &> /dev/null; then
|
||||
terminator -e "ssh $SSH_TARGET"
|
||||
elif command -v tilix &> /dev/null; then
|
||||
tilix -e "ssh $SSH_TARGET"
|
||||
else
|
||||
# Fallback: notification d'erreur si possible
|
||||
if command -v notify-send &> /dev/null; then
|
||||
notify-send "SSH Handler" "Aucun terminal graphique trouvé"
|
||||
fi
|
||||
echo "Erreur: aucun terminal graphique trouvé"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user