aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/ssh-tab
blob: 8e8a3104512946651ea2d1c3de5fd1a52547644e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"