mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-23 08:26:49 +01:00
feat: add more scripts
This commit is contained in:
parent
cd289da742
commit
575db8e773
7 changed files with 99 additions and 9 deletions
13
modules/scripts/ssh-select.bash
Normal file
13
modules/scripts/ssh-select.bash
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Extract hosts from config and known_hosts
|
||||
# shellcheck disable=SC2002
|
||||
hosts=$(cat ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -P "^Host ([^*]+)$" | awk '{print $2}' ; cat ~/.ssh/known_hosts 2>/dev/null | cut -f 1 -d ' ' | sed -e 's/,.*//g' | sort -u)
|
||||
|
||||
selected=$(echo "$hosts" | fzf --prompt="SSH > " --height=20% --layout=reverse)
|
||||
|
||||
if [ -n "$selected" ]; then
|
||||
echo "Connecting to $selected..."
|
||||
ssh "$selected"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue