Commit 3d68ed7
xxwhirlpool
·
2026-07-16 14:21:50 -0400 EDT
parent b4a6652
tailnet switch menu
1 files changed,
+23,
-0
+23,
-0
| ... | ... | @@ -0,0 +1,23 @@ | |
| 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 | |
| 8 | + | ts_list() { | |
| 9 | + | tailscale switch --list | awk 'NR>1 {$3=""; print $0}' | |
| 10 | + | } | |
| 11 | + | ||
| 12 | + | # get the ids only | |
| 13 | + | ts_ids=$(ts_list | awk '{print $0}') | |
| 14 | + | ||
| 15 | + | # turn ids into array | |
| 16 | + | readarray -t ts_array <<< "$ts_ids" | |
| 17 | + | ||
| 18 | + | # prompt user to pick from tailnet list | |
| 19 | + | # shows id + name, awk makes it pick id | |
| 20 | + | choose=$(gum choose "${ts_array[@]}" | awk '{print $1}') | |
| 21 | + | ||
| 22 | + | # do the switch | |
| 23 | + | tailscale switch "$choose" |