1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-09-21 11:00:08 +00:00

Added a segment that displays the current IP address.

This commit is contained in:
Dominik Ritter 2015-08-26 17:36:04 +02:00
parent 2bc5a60c7a
commit b73366f039

View file

@ -115,6 +115,7 @@ case $POWERLEVEL9K_MODE in
LINUX_ICON $'\UE271' # 
SUNOS_ICON $'\U1F31E ' # 🌞
HOME_ICON $'\UE12C' # 
NETWORK_ICON $'\UE1AD' # 
LOAD_ICON $'\UE190 ' # 
#RAM_ICON $'\UE87D' # 
RAM_ICON $'\UE1E2 ' # 
@ -159,6 +160,7 @@ case $POWERLEVEL9K_MODE in
LINUX_ICON 'Lx'
SUNOS_ICON 'Sun'
HOME_ICON ''
NETWORK_ICON ''
LOAD_ICON ''
RAM_ICON ''
VCS_UNTRACKED_ICON '?'
@ -555,6 +557,18 @@ prompt_icons_test() {
done
}
prompt_ip() {
# TODO: Specify Interface by variable!
if [[ "$OS" == "OSX" ]]; then
# Try to get IP addresses from common interfaces.
ip=$(ipconfig getifaddr en0 || ipconfig getifaddr en1)
else
# Take the first IP that `hostname -I` gives us.
ip=$(hostname -I | grep -o "[0-9.]*" | head -n 1)
fi
$1_prompt_segment "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') $ip"
}
prompt_load() {
if [[ "$OS" == "OSX" ]]; then
load_avg_5min=$(sysctl vm.loadavg | grep -o -E -e '[0-9]+\.[0-9]+' | head -n 1)