1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-18 05:40:07 +00:00

Merge pull request #539 from golgoth31/next

add vpn ip to prompt
This commit is contained in:
Ben Hilburn 2017-06-02 12:13:03 -04:00 committed by GitHub
commit b81d2cb2f2
3 changed files with 30 additions and 6 deletions

View file

@ -94,6 +94,7 @@ The segments that are currently available are:
* `history` - The command number for the current line.
* [`host`](#host) - Your current host name
* [`ip`](#ip) - Shows the current IP address.
* [`vpn`](#vpn) - Shows the current VPN IP address.
* [`public_ip`](#public_ip) - Shows your public IP address.
* `load` - Your machine's load averages.
* `os_icon` - Display a nice little icon, depending on your operating system.
@ -445,6 +446,14 @@ specify the correct network interface by setting:
|----------|---------------|-------------|
|`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.|
##### vpn
This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_VPN_IP_INTERFACE`|tun|The VPN NIC type|
##### public_ip
This segment will display your public IP address. There are several methods of obtaining this

View file

@ -84,6 +84,7 @@ case $POWERLEVEL9K_MODE in
LOCK_ICON $'\UE138' # 
EXECUTION_TIME_ICON $'\UE89C' # 
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
)
;;
@ -153,6 +154,7 @@ case $POWERLEVEL9K_MODE in
LOCK_ICON $'\UE138' # 
EXECUTION_TIME_ICON $'\uF253'
SSH_ICON '(ssh)'
VPN_ICON $'\uF023'
KUBERNETES_ICON $'\U2388' # ⎈
)
;;
@ -222,6 +224,7 @@ case $POWERLEVEL9K_MODE in
LOCK_ICON $'\UF023' # 
EXECUTION_TIME_ICON $'\uF252' # 
SSH_ICON $'\uF489' # 
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
)
;;
@ -291,6 +294,7 @@ case $POWERLEVEL9K_MODE in
LOCK_ICON $'\UE0A2'
EXECUTION_TIME_ICON 'Dur'
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
)
;;

View file

@ -914,6 +914,17 @@ prompt_ip() {
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
}
set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun"
# prompt if vpn active
prompt_vpn_ip() {
for vpn_iface in $(ip tuntap | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1)
do
ip=$(ip -4 a show "$vpn_iface" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*")
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON'
done
}
prompt_load() {
# The load segment can have three different states
local current_state="unknown"