main dots / config / .local / bin / ts_switch
xxwhirlpool  ·  2026-07-16
 1#!/usr/bin/env bash
 2#
 3# switch between tailnets
 4# doesn't check for profile access
 5
 6# get a list of tailnets
 7# format is: id name\n
 8ts_list() {
 9	tailscale switch --list | awk 'NR>1 {$3=""; print $0}'
10}
11
12# get the ids only
13ts_ids=$(ts_list | awk '{print $0}')
14
15# turn ids into array
16readarray -t ts_array <<< "$ts_ids"
17
18# prompt user to pick from tailnet list
19# shows id + name, awk makes it pick id
20choose=$(gum choose "${ts_array[@]}" | awk '{print $1}')
21
22# do the switch
23tailscale switch "$choose"