tmux-plugin-sysstat 使用教程

tmux-plugin-sysstat 使用教程

tmux-plugin-sysstatPrints CPU usage, memory & swap, load average, net I/O metrics in Tmux status bar项目地址:https://gitcode.com/gh_mirrors/tm/tmux-plugin-sysstat

1. 项目的目录结构及介绍

tmux-plugin-sysstat 项目的目录结构如下:

tmux-plugin-sysstat/
├── bin/
├── scripts/
├── tmux/
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
└── tmux-plugin-sysstat.tmux
  • bin/: 包含一些用于安装和更新的脚本。
  • scripts/: 包含用于收集系统统计信息的脚本。
  • tmux/: 包含 tmux 配置文件和插件相关的文件。
  • .gitignore: 指定 Git 忽略的文件和目录。
  • .travis.yml: Travis CI 的配置文件。
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的说明文档。
  • tmux-plugin-sysstat.tmux: 插件的入口文件。

2. 项目的启动文件介绍

项目的启动文件是 tmux-plugin-sysstat.tmux。这个文件是插件的入口点,负责加载和初始化插件。

#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CURRENT_DIR/scripts/helpers.sh"

cpu_usage_format="#[fg=#{sysstat_cpu_color}]CPU:#[default] #{cpu_pused}%"
mem_usage_format="#[fg=#{sysstat_mem_color}]MEM:#[default] #{mem_pused}%"
swap_usage_format="#[fg=#{sysstat_swap_color}]SWAP:#[default] #{swap_pused}%"
loadavg_format="#{sysstat_loadavg}"

interpolations=(
    "\#{sysstat_cpu}"
    "\#{sysstat_mem}"
    "\#{sysstat_swap}"
    "\#{sysstat_loadavg}"
)

commands=(
    "$cpu_usage_format"
    "$mem_usage_format"
    "$swap_usage_format"
    "$loadavg_format"
)

do_interpolation() {
    local input=$1
    local result=""

    for ((i=0; i<${#interpolations[@]}; i++)); do
        input=${input//${interpolations[$i]}/${commands[$i]}}
    done

    echo "$input"
}

update_tmux_option() {
    local option=$1
    local option_value=$(get_tmux_option "$option")
    local new_option_value=$(do_interpolation "$option_value")
    set_tmux_option "$option" "$new_option_value"
}

main() {
    update_tmux_option "status-right"
    update_tmux_option "status-left"
}

main

3. 项目的配置文件介绍

tmux-plugin-sysstat 的配置文件通常位于用户的 ~/.tmux.conf 文件中。以下是一个示例配置:

# 启用插件
set -g @plugin 'samoshkin/tmux-plugin-sysstat'

# 配置显示格式
set -g @sysstat_cpu_view_tmpl '#[cpu pused]'
set -g @sysstat_mem_view_tmpl '#Used #[fg=#[mem color]]#[mem used]#[default] out of #[mem total]'
set -g @sysstat_swap_view_tmpl '#Swap #[fg=#[swap color]]#[swap used]#[default] out of #[swap total]'
set -g @sysstat_loadavg_view_tmpl '#Load #[fg=#[loadavg color]]#[loadavg 1]#[default] #[loadavg 5] #[loadavg 15]'

# 配置状态栏
set -g status-right "#[sysstat_cpu] | #[sysstat_mem] | #[sysstat_swap] | #[sysstat_loadavg] | #[fg=cyan]#(echo $USER)#[default]@#H"
  • set -g @plugin 'samoshkin/tmux-plugin-sysstat': 启用插件。
  • set -g @sysstat_cpu_view_tmpl '#[cpu pused]':

tmux-plugin-sysstatPrints CPU usage, memory & swap, load average, net I/O metrics in Tmux status bar项目地址:https://gitcode.com/gh_mirrors/tm/tmux-plugin-sysstat

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

施谨贞Des

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值