config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 99693e82dd5ff56aa2a0b85dc04401640a48914d
parent b7f0f03c1d7445ab69e25302a7fa8def51513727
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu,  3 Sep 2020 20:15:39 -0700

Allow specifying session index at startup

Diffstat:
Mscripts/.local/bin/tat | 18++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/scripts/.local/bin/tat b/scripts/.local/bin/tat @@ -2,14 +2,16 @@ # attach to tmux session via an external menu list() { tmux ls | cut -d: -f1 ;} +nth() { head -n $@ | tail -1 ;} +term() { $TERMINAL -e $@ & } -if [ "$1" = "-e" ] && [ -n "$DISPLAY" ] -then - $TERMINAL -e tmux a -t`list | dmenu` & +if [ "$1" = "-e" ]; then + shift + [ $# -gt 0 ] && session=`list | nth $@` + [ -z "$session" ] && session=`list | dmenu` + [ -n "$session" ] && term tmux a -t $session else - select session in `list` - do - tmux a -t${session:?None selected.} - break; - done + [ $# -gt 0 ] && session=`list | nth $@` + [ -z "$session" ] && select session in `list`; do break; done + [ -n "$session" ] && term tmux a -t $session fi