dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

tmux-session (2031B)


      1 #!/bin/sh
      2 if [ "$1" = "-r" ]
      3 then
      4 	for line in $(tmux list-sessions -F "#S")
      5 	do
      6 		session=$(echo $line | sed 's~:~~')
      7 		columns=$(tput cols)
      8 		echo $session
      9 		case $session in
     10 			iterm|code)
     11 				width=$(($columns - 80))
     12 				;;
     13 			chat|rio)
     14 				width=$(($columns - 20))
     15 				;;
     16 			*)
     17 				unset width
     18 				return
     19 		esac
     20 		if [ -n "$width" ]
     21 		then
     22 			tmux setw -t $session:1 main-pane-width $width
     23 			tmux selectl -t $session:1 main-vertical
     24 		fi
     25 	done
     26 	exit
     27 fi
     28 
     29 if tmux list-sessions 2>/dev/null | grep $1 >/dev/null 2>&1
     30 then
     31 	tmux attach-session -t $1
     32 	exit
     33 fi
     34 
     35 if echo $1 | grep rio > /dev/null 2>&1
     36 then
     37 	name=rio
     38 	columns=$(tput cols)
     39 	tmux new-session -d -x $columns -y $(tput lines) -s $name irssi
     40 	tmux rename-window -t $name:1 chat
     41 	width=$(($columns - 20))
     42 	tmux setw main-pane-width $width
     43 	tmux splitw -h -l 20 cat ~/.irssi/nicklistfifo
     44 	tmux selectl main-vertical
     45 	tmux select-pane -t $name:1.1
     46 	tmux send-keys -t $name:1.1 "/keyring" "C-m" "/nicklist fifo" "C-m"
     47 	tmux new-window -t $name -n "mail" mutt
     48 	tmux new-window -t $name -n "news" newsboat
     49 elif [ $1 = "code" ]
     50 then
     51 	name=code
     52 	columns=$(tput cols)
     53 	width=$(($columns - 80 - 1))
     54 	tmux new-session -d -x $columns -y $(tput lines) -s $name
     55 	tmux rename-window -t $name:1 code
     56 	tmux setw main-pane-width $width
     57 	tmux splitw -h -l 80
     58 	tmux selectl main-vertical
     59 elif [ $1 = "notes" ]
     60 then
     61 	name=notes
     62 	tmux new-session -d -x $(tput cols` -y `tput lines) -s $name sncli
     63 elif [ $1 = "chat" ]
     64 then
     65 	name=chat
     66 	columns=$(tput cols)
     67 	width=$(($columns - 20))
     68 	tmux new-session -d -x $columns -y $(tput lines) -s $name irssi
     69 	tmux setw main-pane-width $width
     70 	tmux splitw -h -l 20 cat ~/.irssi/nicklistfifo
     71 	tmux selectl main-vertical
     72 	tmux send-keys -t $name:1.1 "/keyring" "C-m" "/nicklist fifo" "C-m"
     73 elif [ $1 = "mail" ]
     74 then
     75 	name=mail
     76 	tmux new-session -ds $name mutt
     77 elif [ $1 = "news" ]
     78 then
     79 	name=news
     80 	tmux new-session -ds $name newsboat
     81 fi
     82 
     83 if [ -n "$name" ]
     84 then
     85 	tmux select-window -t $name:1
     86 	tmux select-pane -t $name:1.1
     87 	tmux attach-session -t $name
     88 fi