While wroting some tmux shell scripts I found some dificulties that where not readily resolved on the interwebs root of knowlege. So giving here some of those working scripts for a terminal multiplexer full of potentialities.
This first one is a rss-reader, using rsstail for rss reading and continuous retrieval.
This second one needs root and some administrative tools. It is a monitoring system for log messages and active modules on kernel, and in another window a net monitoring showing all IP connections using lsof and a tcpdump.
Also cool to know are the commands:
Hope you en enjoyed...
This first one is a rss-reader, using rsstail for rss reading and continuous retrieval.
#!/bin/bash
tmux="/usr/bin/tmux"
feedsname="rssfeeds"
urls="http://seclists.org/rss/oss-sec.rss
https://nvd.nist.gov/download/nvd-rss.xml
http://www.debian.org/security/dsa
http://www.linuxsecurity.com/static-content/linuxsecurity_advisories.rss"
first=1
# open rsstopics
rss_reader_cmd="rsstail -trHn 20 -u "
for url in $urls; do
if [[ $first == 1 ]]; then
$tmux new-window -n rss-topics \\"$rss_reader_cmd $url\\"
first=0
else
$tmux split-window \\"$rss_reader_cmd $url\\"
fi
done
$tmux select-layout even-vertical
first=1
#open rssnews
rss_reader_cmd="rsstail -dtcrHn 20 -u "
for url in $urls; do
if [[ $first == 1 ]]; then
$tmux new-window -n rss-news \\"$rss_reader_cmd $url\\"
first=0
else
$tmux split-window \\"$rss_reader_cmd $url\\"
fi
done
$tmux select-layout even-horizontal
This second one needs root and some administrative tools. It is a monitoring system for log messages and active modules on kernel, and in another window a net monitoring showing all IP connections using lsof and a tcpdump.
Another thing I found usefull also was the sccreen lock feature. For this I installed vlock a virtual terminal lock screen app, and configured ~/.tmux.conf with the following lines:#!/bin/bashtmux="/usr/bin/tmux"if [[ $1 == "modules_diff" ]]; thenecho "lsmod diff-----------------"get_module_list="cat /proc/modules"#get_module_list="lsmod"fname1=$(mktemp)fname2=$(mktemp)while [[ 1 ]]; doa="$($get_module_list |tee $fname1)";b="$($get_module_list |tee $fname2)";while [[ "x$a" == "x$b" ]]; dob="$($get_module_list |tee $fname2)";done;df=$(diff -ua $fname1 $fname2 )echo -e "\n\n--\nlsmod changed: (last, current)\n";echo -e "\n\n";doneexit 0fi$tmux new-window -n netlog "watch -n1 lsof -i -n "$tmux split-window "tcpdump -nKHi any "$tmux new-window -n syslog "tail -f /var/log/messages "$tmux split-window "$SHELL $0 modules_diff"$tmux select-layout even-vertical
set-option -g lock-server on
set-option -g lock-command "vlock"
set-option -g lock-after-time 300Tired also of losing output in the window buffer I also set a gigantic history limit (for tmux history are the number of lines to have in the buffer of each pane/window):
set-option -g history-limit 999999999And for the kicks, midnight commander style:
set-option -g status-style "bg=colour25,fg=green,bold"
Also cool to know are the commands:
swap-pane -t <pane_to_swap_with>This swaps the active pane (in the window) with the pane selected with id <pane_to_swap_with>.
break-panebreak-pane takes the active pane of this window and creates a new one with just this pane.
Hope you en enjoyed...
Sem comentários:
Enviar um comentário