From 8ab340269033e30a691d22d12cf4371b7967f594 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Sun, 8 Dec 2024 11:40:30 +0300 Subject: [PATCH] feat(scripts): ssh connect helper --- modules/home-config.nix | 1 + scripts/ssh-connect | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 scripts/ssh-connect diff --git a/modules/home-config.nix b/modules/home-config.nix index 16787ae..8d369b6 100644 --- a/modules/home-config.nix +++ b/modules/home-config.nix @@ -240,6 +240,7 @@ in #tmux = "tmux -f ~/.config/tmux/tmux.conf attach || tmux -f ~/.config/tmux/tmux.conf new"; bunx = "bun --bun x"; g = "lazygit"; + s = "/home/mrflos/Code/nixos-config/scripts/ssh-connect"; t = "/home/mrflos/Code/nixos-config/scripts/tmux-sessionizer"; kdenix = "nix run github:pjones/plasma-manager --extra-experimental-features nix-command --extra-experimental-features flakes > /home/mrflos/Developpements/nixos-config/modules/home-plasma.nix"; icat = "kitty +kitten icat"; diff --git a/scripts/ssh-connect b/scripts/ssh-connect new file mode 100755 index 0000000..11fc960 --- /dev/null +++ b/scripts/ssh-connect @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(grep -P "^Host ([^*]+)$" $HOME/.ssh/config | sed 's/Host //' | sort -r -f | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +ssh $selected