diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2018-01-19 01:27:21 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2018-01-19 01:27:21 -0500 |
| commit | 5ea6e75a796633d32f2ddce373242c972c7b2e1d (patch) | |
| tree | d8e0a39d25d3ae79f41855d959cb8e51f1f90391 | |
| parent | 9c167d5e9117744a4e9fdf255954ebe241aeb845 (diff) | |
| download | dotfiles-5ea6e75a796633d32f2ddce373242c972c7b2e1d.tar.gz dotfiles-5ea6e75a796633d32f2ddce373242c972c7b2e1d.tar.xz | |
Clena up tmux configuration and add a helper script. Tell mkshrc to pull the helper
| -rw-r--r-- | mkshrc | 1 | ||||
| -rw-r--r-- | tmux.conf | 8 | ||||
| -rw-r--r-- | tmux_helper.sh | 27 |
3 files changed, 30 insertions, 6 deletions
@@ -453,6 +453,7 @@ pullsshconfig() { } updatetmuxconf() { pulldotfile "tmux.conf" + pulldotfile "tmux_helper.sh" if ! [ -e $HOME/.tmux.conf.local ] && [ `id -u` -eq 0 ] ; then # If I ever change the color from green this will have to be updated I guess grep 'green' $HOME/.tmux.conf | sed -e's/green/red/g' > $HOME/.tmux.conf.local @@ -39,12 +39,8 @@ 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] " -# Old status line, doesn't quite work right all the time -# set -g status-right "#[fg=green,bg=black] #(whoami)@#h|up:#(uptime | awk '{print $1}' | awk -F: '{print $1}')h " -# Who knew I'd be embedding such a horrible abomination into a tmux configuration file? -set -g status-right "#[fg=green,bg=black] #(whoami)@#h|#( uptime -p | awk 'BEGIN {OFS=\",\";} {print $1, $2, $3}' | sed -re's/^up,([0-9]+),([hmrsdwy]).*$/up:\\1\\2/g' ) " -# If you're on a BSD system copy this line into your ~/.tmux.conf.local -# set -g status-right "#[fg=green,bg=black] #(whoami)@#h|#( uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\\1/g' -e's/^([^ ]+)[ ]*(.).*/\\1\\2/g' )" +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-length 40 set -g window-status-format "#I:#W#F" diff --git a/tmux_helper.sh b/tmux_helper.sh new file mode 100644 index 0000000..7ba09ee --- /dev/null +++ b/tmux_helper.sh @@ -0,0 +1,27 @@ +#!/bin/sh + + +# 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 ... } + +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' + fi +} + +load() { + # Works on BSD too, neat. + uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' +} + +s_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' +} + + +$1 |
