From b359a2406c888db5286a5fd5937f3cb4740b634a Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 7 Nov 2018 23:47:38 -0500 Subject: update helper functions in tmux --- tmux.conf | 5 +++-- tmux_helper.sh | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tmux.conf b/tmux.conf index b6fb6a7..ed59b92 100644 --- a/tmux.conf +++ b/tmux.conf @@ -45,14 +45,15 @@ bind-key M-r respawn-pane # Change the status line a little bit, most are close to defaults set -g status-left-length 16 set -g status-left "[#S] " -set -g status-right "#[fg=green,bg=black] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh s_uptime)" +set -g status-right "#[fg=green,bg=black] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh uptime)" set -g status-right-length 40 set -g window-status-format "#I:#W#F" # If you still want to select text out of the terminal as you normally would -# You should hold the shift key ( Linux ) I'm told it's "Option on Mac OS X" +# You should hold the shift key ( Linux ) Option/Alt works in iTerm2 on MacOS +# Does not seem to work with the native terminal. set -g mouse on # Old mouse method diff --git a/tmux_helper.sh b/tmux_helper.sh index 7ba09ee..7ce68bd 100644 --- a/tmux_helper.sh +++ b/tmux_helper.sh @@ -2,26 +2,27 @@ # Little helper script to clean up the nasty embeded commands in my tmux configuration -# Be careful if you add commands that you don't cause infinite recursion by calling -# a command the same name as an executable on the system you're using. e.g. uptime() { uptime | sed ... } +# Functions ripped out of `mkshrc`, worth checking out -memory() { +_sys_memory() { if [ `uname` = "Linux" ] ; then vmstat | tail -n1 | awk '{print $4/1024}' | sed -e's/\..*$//g' elif [ `uname` = "FreeBSD" ] ; then vmstat | tail -n1 | awk '{print $5/1024}' | sed -e's/\..*$//g' + elif [ `uname` = "OpenBSD" ] ; then + vmstat | sed -n '$p' | awk '{print $4}' | sed 's/M$//' fi } -load() { +_sys_load() { # Works on BSD too, neat. uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' } -s_uptime() { +_sys_uptime() { # Took awhile to figure out, but this works on BSD as well - uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/u:\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' + uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' } -$1 +_sys_$1 -- cgit v1.2.3