Display of free RAM is now configurable.

pull/22/head
Dominik Ritter 9 years ago
parent b8b82eee21
commit f7a05fcd2c

@ -607,17 +607,22 @@ prompt_ip() {
$1_prompt_segment "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') $ip" $1_prompt_segment "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') $ip"
} }
set_default POWERLEVEL9K_LOAD_SHOW_FREE_RAM true
prompt_load() { prompt_load() {
if [[ "$OS" == "OSX" ]]; then if [[ "$OS" == "OSX" ]]; then
load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1) load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+') if [[ "$POWERLEVEL9K_LOAD_SHOW_FREE_RAM" == true ]]; then
# Convert pages into Bytes ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
ramfree=$(( $ramfree * 4096 )) # Convert pages into Bytes
base='' ramfree=$(( $ramfree * 4096 ))
base=''
fi
else else
load_avg_5min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1) load_avg_5min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") if [[ "$POWERLEVEL9K_LOAD_SHOW_FREE_RAM" == true ]]; then
base=K ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
base=K
fi
fi fi
# Replace comma # Replace comma
@ -634,7 +639,11 @@ prompt_load() {
FUNCTION_SUFFIX="_NORMAL" FUNCTION_SUFFIX="_NORMAL"
fi fi
$1_prompt_segment "$0$FUNCTION_SUFFIX" $BACKGROUND_COLOR "$DEFAULT_COLOR" "$(print_icon 'LOAD_ICON') $load_avg_5min $(print_icon 'RAM_ICON') $(printSizeHumanReadable $ramfree $base)" $1_prompt_segment "$0$FUNCTION_SUFFIX" $BACKGROUND_COLOR "$DEFAULT_COLOR" "$(print_icon 'LOAD_ICON') $load_avg_5min"
if [[ "$POWERLEVEL9K_LOAD_SHOW_FREE_RAM" == true ]]; then
echo -n "$(print_icon 'RAM_ICON') $(printSizeHumanReadable $ramfree $base) "
fi
} }
# Right Status: (return code, root status, background jobs) # Right Status: (return code, root status, background jobs)

Loading…
Cancel
Save