Last active
August 16, 2018 18:18
-
-
Save steadystatic/c0f1fb771d4d4bd3356cfb577f37e64e to your computer and use it in GitHub Desktop.
Simple vpn status zsh function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/zsh | |
| # Check PID file and display status before prompt | |
| # Example path could be /Users/mike/.zprezto/modules/prompt/functions/vpn_status | |
| # Usage...customize zsh theme (that has prezto module support)... | |
| # e.g. ~/.zprezto/modules/prompt/external/statusline/prezto/prompt_statusline_setup | |
| # Add this: | |
| # autoload -Uz vpn_status | |
| # add-zsh-hook precmd vpn_status | |
| VPN_PID=/var/run/vpnc/vpnc.pid | |
| # Check for OpenConnect pid | |
| # (pgrep returns 0 for found, 1 for not found) | |
| pgrep -f $VPN_PID | |
| if [[ $? -eq 0 ]]; then | |
| # Connected to VPN | |
| echo -e '\U0001f4f6 \U0002705 \n' | |
| else | |
| # Disconnected | |
| echo -e '\U0001f4f6 \U00026D4 \n' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment