kitty-tmux.sh 533 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. IFS=$'\n\t' # Internal Field Separator, controls word splitting, default is $' \n\t'
  4. term="${1:-kitty}"
  5. lauch_term(){
  6. $term -- tmux \
  7. new-session -As0 \; \
  8. new-window -c "$PWD" -n "${PWD##*/}"
  9. }
  10. # Check if $term and tmux are running
  11. if pgrep "$term" >/dev/null; then
  12. # Terminal with $term and tmux is already running, bring it into focus
  13. wmctrl -x -a "${term}.${term}"
  14. else
  15. # Launch a new terminal with $term and tmux
  16. launch_term
  17. fi