init.zsh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # Defines tmux aliases and provides for auto launching it at start-up.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <sorin.ionescu@gmail.com>
  6. # Colin Hebert <hebert.colin@gmail.com>
  7. # Georges Discry <georges@discry.be>
  8. # Xavier Cambar <xcambar@gmail.com>
  9. #
  10. # Return if requirements are not found.
  11. if (( ! $+commands[tmux] )); then
  12. return 1
  13. fi
  14. #
  15. # Auto Start
  16. #
  17. if ([[ "$TERM_PROGRAM" = 'iTerm.app' ]] && \
  18. zstyle -t ':prezto:module:tmux:iterm' integrate \
  19. ); then
  20. _tmux_iterm_integration='-CC'
  21. fi
  22. if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && "$TERM_PROGRAM" != "vscode" && "$TERMINAL_EMULATOR" != "JetBrains-JediTerm" ]] && ( \
  23. ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) ||
  24. ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \
  25. ); then
  26. tmux start-server
  27. # Create a 'prezto' session if no session has been defined in tmux.conf.
  28. if ! tmux has-session 2> /dev/null; then
  29. zstyle -s ':prezto:module:tmux:session' name tmux_session || tmux_session='prezto'
  30. tmux \
  31. new-session -d -s "$tmux_session" \; \
  32. set-option -t "$tmux_session" destroy-unattached off &> /dev/null
  33. fi
  34. # Attach to the 'prezto' session or to the last session used. (detach first)
  35. exec tmux $_tmux_iterm_integration attach-session -d
  36. fi
  37. #
  38. # Aliases
  39. #
  40. if ! zstyle -t ':prezto:module:tmux:alias' skip; then
  41. alias tmuxa="tmux $_tmux_iterm_integration new-session -A"
  42. alias tmuxl='tmux list-sessions'
  43. fi