scripts

Scripts for general automations
git clone git://git.laack.co/scripts.git
Log | Files | Refs

attach.sh (582B)


      1 #!/bin/bash
      2 
      3 # if $1 != '' then we are to assume this is being ran without a terminal
      4 # session. If this is the case, create a new terminal and tmux session.
      5 
      6 
      7 # running non-interactively
      8 if [ -n "$1" ]; then
      9 
     10 	prompt="session:"
     11 	dmenu_cmd="dmenu -p \"$prompt\""
     12 	selection=$(tmux ls | awk '{print $1}' | sed 's/:$//' | eval $dmenu_cmd)
     13 
     14 	if [ -z "$selection" ]; then
     15 		exit 0
     16 	fi
     17 
     18 	st -e tmux attach -t $selection
     19 
     20 else
     21 # running interactively
     22 	selection=$(tmux ls | awk '{print $1}' | sed 's/:$//' | fzf)
     23 
     24 	if [ -z "$selection" ]; then
     25 		exit 0
     26 	fi
     27 
     28 	tmux attach -t $selection
     29 fi