#!/usr/bin/env bash source ~/.dotfiles/nfrc.sh which tailscale > /dev/null || { echo Tailscale not installed exit 1 } [ -z "$1" ] && { echo "No args" exit 1 } case "$1" in "u"|"up") endpoint=$2 [ -z "$endpoint" ] && { endpoint=$(tailscale status | grep "exit node" | awk '{print $2}' | $FMENU 'Select server') [ -z "$endpoint" ] && exit 1 } tailscale set --exit-node="$endpoint" tailscale up ;; "d"|"down") tailscale set --exit-node= tailscale up ;; esac