Skip to content

Instantly share code, notes, and snippets.

@tyjak
Last active October 6, 2023 06:53
Show Gist options
  • Save tyjak/089d542d3f862d15cf2c088c1ec5bba0 to your computer and use it in GitHub Desktop.
Save tyjak/089d542d3f862d15cf2c088c1ec5bba0 to your computer and use it in GitHub Desktop.
dmenu-ssh simple dmenu to connect to your ssh server listed in .ssh/config file
#!/bin/sh
# Dmenu for ssh connection
# Take two ssh config files, the default user and a config file for work serveur via $SSH_WORK_CONFIG_FILE
hosts_menu=$(grep '^Host\b [^*]\+\b' $HOME/.ssh/config $SSH_WORK_CONFIG_FILE | awk '{$1=""; print $0}' | dmenu -p "SSH servers:" -l 10 -i -nb '#b58900' -nf '#eee8d5' -sb '#002b24' -fn 'MesloLGSDZ Nerd Font-10' -h ${DMENUHEIGHT:-36})
host_target=$(echo $hosts_menu | cut -d' ' -f1)
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
fi
echo "UPDATESTARTUPTTY" | gpg-connect-agent > /dev/null 2>&1
cat $HOME/.ssh/config $SSH_WORK_CONFIG_FILE > $HOME/.ssh/.config_global
alacritty --title " $host_target" -e ssh -F $HOME/.ssh/.config_global $host_target 'LANG=fr_FR.UTF-8 tmux attach || LANG=fr_FR.UTF-8 tmux new-session'
# GistID: 089d542d3f862d15cf2c088c1ec5bba0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment