Only run Windows commands if inside WSL, even if @x_wsl is set

This commit is contained in:
PastaMasta 2023-05-31 22:57:48 +01:00
parent bf373e7a0d
commit 559f9a43f4
3 changed files with 4 additions and 2 deletions

View file

@ -165,6 +165,8 @@ If you're running on WSL you can set these options to get the CPU / RAM values f
@ram_wsl 'true # true/false
```
Note this only works if `$WSL_DISTRO_NAME` is also set, which is done by default inside WSL.
### Tmux Plugins
This plugin is part of the [tmux-plugins](https://github.com/tmux-plugins) organisation. Checkout plugins as [battery](https://github.com/tmux-plugins/tmux-battery), [logging](https://github.com/tmux-plugins/tmux-logging), [online status](https://github.com/tmux-plugins/tmux-online-status), and many more over at the [tmux-plugins](https://github.com/tmux-plugins) organisation page.

View file

@ -10,7 +10,7 @@ cpu_percentage_format="%3.1f%%"
print_cpu_percentage() {
cpu_percentage_format=$(get_tmux_option "@cpu_percentage_format" "$cpu_percentage_format")
if $(get_tmux_option @cpu_wsl) == "true" ; then
if $(get_tmux_option @cpu_wsl) == "true" && test -n "${WSL_DISTRO_NAME}" ; then
load="$(cached_eval wmic.exe cpu get LoadPercentage | grep -Eo '^[0-9]+')"
echo "$load" | awk -v format="$cpu_percentage_format" '{printf format, $1}'
elif command_exists "iostat"; then

View file

@ -15,7 +15,7 @@ sum_macos_vm_stats() {
print_ram_percentage() {
ram_percentage_format=$(get_tmux_option "@ram_percentage_format" "$ram_percentage_format")
if $(get_tmux_option @ram_wsl) == "true" ; then
if $(get_tmux_option @ram_wsl) == "true" && test -n "${WSL_DISTRO_NAME}"; then
# TotalPhysicalMemory is in bytes, but FreePhysicalMemory is in KiB
total=$(wmic.exe ComputerSystem get TotalPhysicalMemory | awk '/^[0-9]/{print $1/1024}')