Advertisement
Guest User

Simple Tmux Wrapper

a guest
Sep 24th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function usage() {
  4.     echo "tmx <session>"
  5. }
  6.  
  7. sess=${1:-def}
  8.  
  9. running_sessions=$(tmux list-sessions | cut -d: -f 1)
  10. found=false
  11.  
  12. for s in ${running_sessions};
  13. do
  14.     if [[ "${s}" = "${sess}" ]]; then
  15.         found=true
  16.     fi
  17. done
  18.  
  19. if [[ "${found}" = "true" ]]; then
  20.     exec tmux attach-session -t "${sess}"
  21. else
  22.     exec tmux new-session -s "${sess}"
  23. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement