Skip to content

Commit c21246e

Browse files
fix: use plain awk for the load status line module, removing a dep (#508)
This removes the dependency on an external script to get system load, and uses the suggested script from the tmux wiki instead. --------- Co-authored-by: Kaley Main <[email protected]>
1 parent 073ee54 commit c21246e

File tree

5 files changed

+30
-22
lines changed

5 files changed

+30
-22
lines changed

‎docs/reference/status-line.md‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,12 @@ run '~/.tmux/plugins/tpm/tpm'
153153

154154
## Load module
155155

156-
**Requirements:** This module depends on [tmux-loadavg](https://github.com/jamesoff/tmux-loadavg).
157-
158-
**Install:** The preferred way to install tmux-loadavg is using [TPM](https://github.com/tmux-plugins/tpm).
159-
160156
**Configure:**
161157

162158
```sh
163159
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
164160

165161
set -agF status-right "#{E:@catppuccin_status_load}"
166-
167-
set -g @plugin 'jamesoff/tmux-loadavg'
168-
run '~/.tmux/plugins/tpm/tpm'
169162
```
170163

171164
## Gitmux module
@@ -192,20 +185,20 @@ Add the following to your `~/.gitmux.conf` so that it uses catppuccin colors:
192185

193186
```yaml
194187
tmux:
195-
styles:
196-
clear: '#[fg=#{@thm_fg}]'
197-
state: '#[fg=#{@thm_red},bold]'
198-
branch: '#[fg=#{@thm_fg},bold]'
199-
remote: '#[fg=#{@thm_teal}]'
200-
divergence: '#[fg=#{@thm_fg}]'
201-
staged: '#[fg=#{@thm_green},bold]'
202-
conflict: '#[fg=#{@thm_red},bold]'
203-
modified: '#[fg=#{@thm_yellow},bold]'
204-
untracked: '#[fg=#{@thm_mauve},bold]'
205-
stashed: '#[fg=#{@thm_blue},bold]'
206-
clean: '#[fg=#{@thm_rosewater},bold]'
207-
insertions: '#[fg=#{@thm_green}]'
208-
deletions: '#[fg=#{@thm_red}]'
188+
styles:
189+
clear: "#[fg=#{@thm_fg}]"
190+
state: "#[fg=#{@thm_red},bold]"
191+
branch: "#[fg=#{@thm_fg},bold]"
192+
remote: "#[fg=#{@thm_teal}]"
193+
divergence: "#[fg=#{@thm_fg}]"
194+
staged: "#[fg=#{@thm_green},bold]"
195+
conflict: "#[fg=#{@thm_red},bold]"
196+
modified: "#[fg=#{@thm_yellow},bold]"
197+
untracked: "#[fg=#{@thm_mauve},bold]"
198+
stashed: "#[fg=#{@thm_blue},bold]"
199+
clean: "#[fg=#{@thm_rosewater},bold]"
200+
insertions: "#[fg=#{@thm_green}]"
201+
deletions: "#[fg=#{@thm_red}]"
209202
```
210203
211204
## Pomodoro module

‎run_tests.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
1010
"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/application_module.sh --expected "${script_dir}"/tests/application_module_expected.txt "$@"
1111
"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/battery_module.sh --expected "${script_dir}"/tests/battery_module_expected.txt "$@"
1212
"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/cpu_module.sh --expected "${script_dir}"/tests/cpu_module_expected.txt "$@"
13+
"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/load_module.sh --expected "${script_dir}"/tests/load_module_expected.txt "$@"
1314
"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/pane_styling.sh --expected "${script_dir}"/tests/pane_styling_expected.txt "$@"

‎status/load.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
set -ogq "@catppuccin_${MODULE_NAME}_icon" "ó°Šš "
55
set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_blue}"
6-
set -ogq "@catppuccin_${MODULE_NAME}_text" " #{load_full}"
6+
set -ogq "@catppuccin_${MODULE_NAME}_text" "#{l:#(uptime | awk '{split(substr($0, index($0, \"load\")), a, \":\"); print a[2]\}}')"
77

88
source -F "#{d:current_file}/../utils/status_module.conf"

‎tests/load_module.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
4+
# shellcheck disable=SC1091
5+
source "${script_dir}/helpers.sh"
6+
7+
# Tests that the default options are set correctly
8+
tmux source "${script_dir}/../catppuccin_options_tmux.conf"
9+
tmux source "${script_dir}/../catppuccin_tmux.conf"
10+
11+
print_option E:@catppuccin_status_load
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
E:@catppuccin_status_load #[fg=#89b4fa]î‚¶#[fg=#11111b,bg=#89b4fa]ó°Šš #[fg=#cdd6f4,bg=#313244]#(uptime | awk '{split(substr($0, index($0, "load")), a, ":"); print a[2]}')#[fg=#313244]
3+

0 commit comments

Comments
 (0)