Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

toggle-xterm

By: a guest on Jan 7th, 2012  |  syntax: Bash  |  size: 0.30 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # mfk
  4. #
  5. # usage: toggle-xterm COMMAND
  6. #
  7. # if COMMAND is running in an xterm close the term; otherwise start  COMMAND in
  8. # an xterm.
  9. #
  10. # requires wmctrl
  11.  
  12. title="|> $@ <|"
  13. if wmctrl -l | grep "$title" >/dev/null ; then
  14.     wmctrl -F -c "$title"
  15. else
  16.     xterm -T "$title" -e $@ &
  17. fi