aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/ssh-tab
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/ssh-tab')
-rwxr-xr-xhosts/ssh-tab24
1 files changed, 24 insertions, 0 deletions
diff --git a/hosts/ssh-tab b/hosts/ssh-tab
new file mode 100755
index 0000000..8e8a310
--- /dev/null
+++ b/hosts/ssh-tab
@@ -0,0 +1,24 @@
+#!/bin/bash
+# ssh-tab - ssh to an alias in a tab of the running kitty
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# Lifted from blackpearl-sshmenu.sh, the rofi menu this shell replaces.
+# A tab in the running kitty, through the socket kitty.conf's listen_on opens;
+# a new terminal when no kitty is up.
+# ponytail: first socket wins when several kitty instances run.
+name=${1:?usage: ssh-tab <alias>}
+sockets=("$XDG_RUNTIME_DIR"/kitty-*)
+if [[ -S ${sockets[0]} ]] && kitten @ --to "unix:${sockets[0]}" launch \
+ --type=tab --tab-title "$name" ssh "$name" >/dev/null; then
+ exec hyprctl dispatch 'hl.dsp.focus({ window = "class:kitty" })' >/dev/null
+fi
+exec kitty ssh "$name"