File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 15
15
16
16
# @Documentation:
17
17
# @raycast.description Switches Tailscale networks
18
+
19
+ # Original author
18
20
# @raycast.author Ross Zurowski
19
21
# @raycast.authorURL https://github.com/rosszurowski
20
22
23
+ # Contributor
24
+ # @raycast.author Daniel Schoemer
25
+ # @raycast.authorURL https://github.com/quatauta
26
+
21
27
ts=" "
22
28
23
29
if command -v tailscale & > /dev/null; then
29
35
exit 1
30
36
fi
31
37
32
- $ts logout
33
- $ts up
38
+ " ${ts} " switch --list | # List all Tailscale accounts "<ID> <Tailnet name> <User account name>"
39
+ grep -vF -e ' ID' -e ' *' | # Omit the header line and the current account marked with "*"
40
+ awk ' { print $1 }' | # Print only the account ID of not-connected accounts
41
+ head -n1 | # Print only the first not-connected account
42
+ xargs -r -n1 " ${ts} " switch # Switch to the selected account
34
43
35
- if command -v jq & > /dev/null; then
36
- account=$( $ts status --json | jq -r ' .User[(.Self.UserID | tostring)].LoginName' )
37
- echo " Connected as $account "
38
- else
39
- echo " Connected"
40
- fi
44
+ tailnet=" $( " ${ts} " switch --list | awk ' /\*/ { print $2 }' ) "
45
+ echo " Switched to ${tailnet} "
You can’t perform that action at this time.
0 commit comments