Package: powerline-tailscale
Powerline TailscaleA Powerline segment for showing the status of TailscaleSince Tailscale doesn't (seemingly) have a configuration file where it reads and stores state, this segment implementation relies on thetailscaledAPI server. I haven't found any official documentation regarding it, but its capabilities are availablehere. There exists a Python library to interact with this API in limited form called'tailscale-localapi', though I decided against using it because I didn't want to introduce any Python-specific dependencies; this is something I may reconsider in the future keeping in mind that the current implementation relies oncurlinstead.RequirementsBesides having Tailscale installed according to theofficial documentation, it is also necessary to installcurlat either 7.40.0 or above, which is when the--unix-socketflag was introduced. You can check your version ofcurlwith the--versionflag:$curl--versioncurl 7.85.0 (x86_64-redhat-linux-gnu) libcurl/7.85.0 OpenSSL/3.0.9 zlib/1.2.12 brotli/1.0.9 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.3) libssh/0.10.5/openssl/zlib nghttp2/1.51.0Release-Date: 2022-08-31Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftpFeatures: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSocketsIfcurlor Tailscale isn't installed ortailscaledisn't running, then installing and configuring this segment will have no effect.InstallationUsing Pip:pipinstallpowerline-tailscaleConfigurationOnly three highlight groups are necessary to be defined in order forpowerline-tailscaleto work. These can be set up in~/.config/powerline/colorschemes/default.json. You are free to choose any colors you want.{"name":"Default","groups":{"tailscale":{"fg":"white","bg":"gray2","attrs":[]},"tailscale_exitnode":{"fg":"white","bg":"steelblue","attrs":[]},"tailscale:divider":{"fg":"white","bg":"steelblue","attrs":[]}}}After that, add the segment's configuration by modifying the relevant Powerline theme. If you are using the default, then in~/.config/powerline/themes/shell/default.json:{"function":"powerline_tailscale.tailscale","args":{"show_profile_name":true,"show_exit_node_status":false,"show_exit_node":true}}Now, just reload Powerline usingpowerline-daemon --replace.Optionsshow_profile_nameshows either:"logged out" iftailscaledis running, but no account is logged in;"default" if no profile is created, i.e. the log-in hasn't been done withtailscale login --nickname=<name>;or the name of the profile itself;show_exit_node_statusshows a boolean "exit node (y)" or "exit node (n)" depending on whether connected to an exit node throughtailscale up --exit-node="<IP>"show_exit_nodeshows the actual IP address of the exit node as given totailscale up --exit-node="<IP>"theshow_exit_node_statusoption needs to be set tofalsewhen this option is set totrueif not connected to an exit node, then "exit node (n)" is shownDisablingBy default the segment will always be displayed, but you may wish to toggle it instead. This can be done through a Bash function, which unsets or sets an environment variable that the segment reads:functionplts(){if[[$POWERLINE_TAILSCALE="0"]];thenunsetPOWERLINE_TAILSCALEelseexportPOWERLINE_TAILSCALE=0fi}You can add this function to your~/.bashrcfile, source it usingsource ~/.bashrc, and then toggle the segment usingpltsor whatever you chose for the name of the function. This function name can also be Tab-completed.If you want to start your shell sessionswithouthaving this segment, then addexport POWERLINE_TAILSCALE="0"somewhere in~/.bashrc.