aboutsummaryrefslogtreecommitdiffstats
path: root/shlib/tmux.sh
blob: c8870f5a1edc3b3a6f0e8d7697df52ae1b65e5bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# shellcheck shell=sh
[ -n "${DOTFILES_TMUX_LOADED}" ] && return
readonly DOTFILES_TMUX_LOADED=1

. "$(dirname "$0")/shlib/log.sh"

tmux_setup_tpm() {
  (
    tpm_dir="$HOME/.config/tpm/plugins/tpm"
    if [ ! -d "$tpm_dir" ]; then
      log_info "Cloning TPM..."
      if ! git clone https://github.com/tmux-plugins/tpm "$tpm_dir"; then
        log_error "Failed to clone tpm to $tpm_dir"
        return 1
      fi
    else
      log_info "TPM already exists, updating..."
      (cd "$tpm_dir" && git pull)
    fi

    if command -v tmux >/dev/null 2>&1; then
      log_info "Installing tmux plugins..."
      "$tpm_dir/scripts/install_plugins.sh"
      log_info "TPM plugins installed successfully."
    else
      log_warn "tmux not found. TPM cloned but plugins not installed."
      log_warn "Run 'tmux' and then press 'prefix + I' to install plugins manually."
    fi
  )
}