mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 04:10:07 +00:00
Split up ram
segment into ram
and swap
.
This commit is contained in:
parent
472fb6f674
commit
6aadf76397
4 changed files with 47 additions and 47 deletions
|
@ -1,3 +1,10 @@
|
|||
## v0.4.0 (next)
|
||||
|
||||
### `ram` changes
|
||||
|
||||
The `ram` segment was split up into `ram` and `swap`. The `POWERLEVEL9K_RAM_ELEMENTS`
|
||||
variable is void.
|
||||
|
||||
## v0.3.1
|
||||
|
||||
### `dir` changes
|
||||
|
|
|
@ -94,12 +94,13 @@ The segments that are currently available are:
|
|||
* **nvm** - Show the version of Node that is currently active, if it differs from the version used by NVM
|
||||
* **os_icon** - Display a nice little icon, depending on your operating system.
|
||||
* **php_version** - Show the current PHP version.
|
||||
* [ram](#ram) - Show free RAM and used Swap.
|
||||
* **ram** - Show free RAM
|
||||
* [rbenv](#rbenv) - Ruby environment information (if one is active).
|
||||
* **root_indicator** - An indicator if the user is root.
|
||||
* [rspec_stats](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
|
||||
* **rust_version** - Display the current rust version.
|
||||
* [status](#status) - The return code of the previous command.
|
||||
* **swap** - Prints the current swap size.
|
||||
* [symphony2_tests](#symphony2_tests) - Show a ratio of test classes vs code classes for Symfony2.
|
||||
* **symphony2_version** - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
|
||||
* [time](#time) - System time.
|
||||
|
@ -253,12 +254,6 @@ This segment shows the return code of the last command.
|
|||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to hide this segment when the last command completed successfully.|
|
||||
|
||||
##### ram
|
||||
|
||||
| Variable | Default Value | Description |
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.|
|
||||
|
||||
##### symphony2_tests
|
||||
|
||||
See [Unit Test Ratios](#unit-test-ratios), below.
|
||||
|
|
|
@ -48,7 +48,7 @@ case $POWERLEVEL9K_MODE in
|
|||
FOLDER_ICON $'\UE818' #
|
||||
NETWORK_ICON $'\UE1AD' #
|
||||
LOAD_ICON $'\UE190 ' #
|
||||
#RAM_ICON $'\UE87D' #
|
||||
SWAP_ICON $'\UE87D' #
|
||||
RAM_ICON $'\UE1E2 ' #
|
||||
VCS_UNTRACKED_ICON $'\UE16C' #
|
||||
VCS_UNSTAGED_ICON $'\UE17C' #
|
||||
|
@ -101,6 +101,7 @@ case $POWERLEVEL9K_MODE in
|
|||
FOLDER_ICON $'\UF115' #
|
||||
NETWORK_ICON $'\UF09E' #
|
||||
LOAD_ICON $'\UF080 ' #
|
||||
SWAP_ICON $'\UF0E4' #
|
||||
RAM_ICON $'\UF0E4' #
|
||||
VCS_UNTRACKED_ICON $'\UF059' #
|
||||
VCS_UNSTAGED_ICON $'\UF06A' #
|
||||
|
@ -149,6 +150,7 @@ case $POWERLEVEL9K_MODE in
|
|||
FOLDER_ICON ''
|
||||
NETWORK_ICON 'IP'
|
||||
LOAD_ICON 'L'
|
||||
SWAP_ICON 'SWP'
|
||||
RAM_ICON 'RAM'
|
||||
VCS_UNTRACKED_ICON '?'
|
||||
VCS_UNSTAGED_ICON $'\u25CF' # ●
|
||||
|
|
|
@ -565,46 +565,18 @@ prompt_php_version() {
|
|||
|
||||
# Show free RAM and used Swap
|
||||
prompt_ram() {
|
||||
defined POWERLEVEL9K_RAM_ELEMENTS || POWERLEVEL9K_RAM_ELEMENTS=(ram_free swap_used)
|
||||
local base=''
|
||||
local ramfree=0
|
||||
if [[ "$OS" == "OSX" ]]; then
|
||||
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
|
||||
# Convert pages into Bytes
|
||||
ramfree=$(( ramfree * 4096 ))
|
||||
else
|
||||
ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
base='K'
|
||||
fi
|
||||
|
||||
local rendition base
|
||||
for element in "${POWERLEVEL9K_RAM_ELEMENTS[@]}"; do
|
||||
case $element in
|
||||
ram_free)
|
||||
if [[ "$OS" == "OSX" ]]; then
|
||||
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
|
||||
# Convert pages into Bytes
|
||||
ramfree=$(( ramfree * 4096 ))
|
||||
base=''
|
||||
else
|
||||
ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
base=K
|
||||
fi
|
||||
|
||||
rendition+="$(printSizeHumanReadable "$ramfree" $base) "
|
||||
;;
|
||||
swap_used)
|
||||
if [[ "$OS" == "OSX" ]]; then
|
||||
raw_swap_used=$(sysctl vm.swapusage | grep -o "used\s*=\s*[0-9,.A-Z]*" | grep -o "[0-9,.A-Z]*$")
|
||||
typeset -F 2 swap_used
|
||||
swap_used=${$(echo $raw_swap_used | grep -o "[0-9,.]*")//,/.}
|
||||
# Replace comma
|
||||
swap_used=${swap_used//,/.}
|
||||
|
||||
base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$")
|
||||
else
|
||||
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_used=$(( swap_total - swap_free ))
|
||||
base=K
|
||||
fi
|
||||
|
||||
rendition+="$(printSizeHumanReadable "$swap_used" $base) "
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "${rendition% }" 'RAM_ICON'
|
||||
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
|
||||
}
|
||||
|
||||
# rbenv information
|
||||
|
@ -669,6 +641,30 @@ prompt_status() {
|
|||
fi
|
||||
}
|
||||
|
||||
prompt_swap() {
|
||||
local swap_used=0
|
||||
local base=''
|
||||
|
||||
if [[ "$OS" == "OSX" ]]; then
|
||||
local raw_swap_used
|
||||
raw_swap_used=$(sysctl vm.swapusage | grep -o "used\s*=\s*[0-9,.A-Z]*" | grep -o "[0-9,.A-Z]*$")
|
||||
|
||||
typeset -F 2 swap_used
|
||||
swap_used=${$(echo $raw_swap_used | grep -o "[0-9,.]*")//,/.}
|
||||
# Replace comma
|
||||
swap_used=${swap_used//,/.}
|
||||
|
||||
base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$")
|
||||
else
|
||||
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_used=$(( swap_total - swap_free ))
|
||||
base='K'
|
||||
fi
|
||||
|
||||
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON'
|
||||
}
|
||||
|
||||
# Symfony2-PHPUnit test ratio
|
||||
prompt_symfony2_tests() {
|
||||
if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then
|
||||
|
|
Loading…
Reference in a new issue