dotwryn/scwrypts/remote/remote.scwrypts.zsh

50 lines
1.2 KiB
Bash
Raw Normal View History

2025-02-19 21:58:02 -07:00
readonly ${scwryptsgroup}__type=zsh
readonly ${scwryptsgroup}__color=$(utils.colors.blue)
2025-02-19 21:58:02 -07:00
#####################################################################
2024-04-13 16:57:22 -06:00
DEPENDENCIES+=(yq)
2025-02-19 21:58:02 -07:00
REMOTE_CONNECTIONS_FILE="${XDG_CONFIG_HOME:-${HOME}/.config}/wryn/remote-connections.toml"
2025-02-19 21:58:02 -07:00
${scwryptsgroup}.list-available() {
2024-04-13 16:57:22 -06:00
[ -f "$REMOTE_CONNECTIONS_FILE" ] || {
mkdir -p "$(dirname -- "$REMOTE_CONNECTIONS_FILE")" &>/dev/null
echo "
[sessions]
[sessions.$(hostnamectl --static)]
enabled = true
host = 'localhost'
2024-04-13 16:57:22 -06:00
" | sed 's/^\s\+//; 1d; $d;' > "$REMOTE_CONNECTIONS_FILE"
}
2024-04-13 16:57:22 -06:00
{
yq -oy -r '.sessions | keys | .[]' "$REMOTE_CONNECTIONS_FILE" \
| sed 's|^|connect/|'
2024-04-13 16:57:22 -06:00
echo "tmux/omni"
echo "configure"
echo "test"
2025-02-19 21:58:02 -07:00
} | sed "s|^|zsh/|"
2024-04-13 16:57:22 -06:00
}
2025-02-19 21:58:02 -07:00
${scwryptsgroup}.zsh.get-runstring() {
2024-04-13 16:57:22 -06:00
local SCWRYPT_FILENAME
case $SCWRYPT_NAME in
2025-02-19 21:58:02 -07:00
connect/* )
SCWRYPT_FILENAME="$(scwrypts.config.group remote root)/connect"
2024-04-13 16:57:22 -06:00
echo "export REMOTE__TARGET=$(echo $SCWRYPT_NAME | sed 's|^.*connect/||')"
;;
* )
2025-02-19 21:58:02 -07:00
SCWRYPT_FILENAME="$(scwrypts.config.group remote root)/$SCWRYPT_NAME"
2024-04-13 16:57:22 -06:00
;;
esac
2025-02-19 21:58:02 -07:00
scwrypts.get-runstring.zsh.generic
}
remote.config.yq() {
utils.yq -oy -r $@ "${REMOTE_CONNECTIONS_FILE}" \
| grep -v ^null$
}