Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uptime): replace plugin with sed #163

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ Available modules:
- user - display the username
- host - display the hostname
- date_time - display the date and time
- uptime - display the uptime
- [battery](#battery-module) - display the battery

### Customizing modules
Expand Down Expand Up @@ -438,28 +439,6 @@ Add the load module to the status modules list.
set -g @catppuccin_status_modules_right "... load ..."
```

### Uptime module

#### Requirements
This module depends on [tmux-uptime](https://github.com/robhurring/tmux-uptime).

#### Install
The preferred way to install tmux-uptime is using [TPM](https://github.com/tmux-plugins/tpm).

#### Configure
Load tmux-uptime after you load catppuccin.

```sh
set -g @plugin 'catppuccin/tmux'
...
set -g @plugin 'robhurring/tmux-uptime'
```

Add the uptime module to the status modules list.
```sh
set -g @catppuccin_status_modules_right "... uptime ..."
```

## Create a custom module

It is possible to add a new custom module or overwrite any of the existing modules.
Expand Down
5 changes: 2 additions & 3 deletions status/uptime.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Requires https://github.com/robhurring/tmux-uptime.
show_uptime() {
local index=$1
local icon="$(get_tmux_option "@catppuccin_uptime_icon" "󰔟")"
local color="$(get_tmux_option "@catppuccin_uptime_color" "$thm_green")"
local text="$(get_tmux_option "@catppuccin_uptime_text" "#{uptime}")"
local text="$(get_tmux_option "@catppuccin_uptime_text" "#(uptime | sed 's/^[^,]*up *//; s/, *[[:digit:]]* users.*//; s/ day.*, */d /; s/:/h /; s/ min//; s/$/m/')")"

local module=$( build_status_module "$index" "$icon" "$color" "$text" )
local module=$(build_status_module "$index" "$icon" "$color" "$text")

echo "$module"
}