From 79a108bf2c666f71bdd2d33310b9819e29e0c46a Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Fri, 26 Jan 2024 16:17:54 +0100 Subject: [PATCH] add tmux config, change alacritty borders --- .config/alacritty/alacritty.toml | 4 ++-- .tmux.conf | 37 ++++++++++++++++++++++++++++++++ tmux.sh | 24 +++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .tmux.conf create mode 100755 tmux.sh diff --git a/.config/alacritty/alacritty.toml b/.config/alacritty/alacritty.toml index 00a8285..7c27a6f 100644 --- a/.config/alacritty/alacritty.toml +++ b/.config/alacritty/alacritty.toml @@ -14,8 +14,8 @@ size = 17 [window] decorations = "None" -padding = { x = 10, y = 10 } -dynamic_padding = true +padding = { x = 12, y = 12 } +dynamic_padding = false [bell] duration = 10 diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..21bd8df --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,37 @@ +# Source changes without restarting tmux: +# tmux source-file ~/.tmux.conf + +# I don't know +set -g mouse on + +# Mouse scroll speed +set -g @scroll-speed-num-lines-per-scroll 5 + +# Vi mode to copy things from terminal +setw -g mode-keys vi + +# Count panes from 1 +set -g base-index 1 +setw -g pane-base-index 1 + +# Status bar stuff +set -g status-style fg=#9d7cd8,bg=#16161e +set-window-option -g window-status-current-style bg=#3e3158 +set -g status-position top +set -g status-interval 10 +set -g status-left-length 120 +set -g status-left ' New: 󰘴bc Ren: 󰘴b, Go: 󰘴b ' +set -g status-justify centre +set -g status-right "#( ~/tmux.sh )" +set -g status-right-length 120 + +# Get good colors +set-option -g default-terminal "screen-256color" +set -g default-terminal "tmux-256color" +set -ga terminal-overrides ",*256col*:Tc" +set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' +set-environment -g COLORTERM "truecolor" + +# Display messages longer (ms) +set-option -g display-time 4000 + diff --git a/tmux.sh b/tmux.sh new file mode 100755 index 0000000..3b569d7 --- /dev/null +++ b/tmux.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# This is not as good as activity monitor, as it shows per-core not overall usage +cpu=$(ps -Ac -o %cpu,comm | sort -nk1 | grep -vE "(top)" | tail -1 \ + | awk -v OFMT=%.0f '{print int($1+0.5)"%",$2,$3}') + +# nettop needs at least two samples (-L 2) to calculate a delta +# the beasty awk then throws away the first 50% samples (n=50) with bogus data +# and sorts it by bytes_in +bandwidth=$(nettop -t wifi -P -J bytes_in,bytes_out -d -x -L 2 \ + | grep -v '^time' | sort -k1 | awk -v n=50 '{a[FNR]=$0; \ + min=FNR-int(FNR*n/100)} {i=min; while(i in a) delete a[i--]} \ + END{for(i=min+1;i<=FNR;++i) print a[i]}' - | sed 's/,$//' \ + | sed 's#\.[0-9]*##g' | sort -t',' -k 3 -n | tail -1 | \ + awk -F',' {'print $2,"↓ "int($3/1000) " KB/s ↑",int($4/1000) " KB/s"'} +) + +# Pings the default gateway and returns avg ping. Three ping counts recommended +# for a reasonably meaningful average +rtt=$(ping -t 2 -q -c 3 "$(route -n get default | awk '$1 ~ "gateway:" \ + {print $2}')" | awk -F'/' '$1 ~ "round-trip" {print int($5) " ms"}') + +# Icons are shipped with a font from https://www.nerdfonts.com/font-downloads +echo "󱍢 $rtt  $bandwidth  $cpu"