all repos

tmux-stare @ 0471e155d021d674189d4c7a1388857b518b3972

session manager, but my session manager

tmux-stare/stare.tmux (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
make easier to delete sessions, 6 days ago
1
#!/usr/bin/env bash
2
set -x
3
4
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
source "$CURRENT_DIR/scripts/helpers.sh"
6
7
add_save_interpolation() {
8
  local status_right_value="$(get_tmux_option "status-right" "")"
9
  local save_interpolation="#($CURRENT_DIR/scripts/_auto_save.sh)"
10
11
  if [[ "$status_right_value" != *"$save_interpolation"* ]]; then
12
    set_tmux_option "status-right" "${save_interpolation}${status_right_value}"
13
  fi
14
}
15
16
main() {
17
  local pick_key="$(get_opt_pick)"
18
  [[ -n "$pick_key" ]] && tmux bind-key "$pick_key" run-shell "$CURRENT_DIR/scripts/_pick.sh"
19
20
  local save_key="$(get_opt_save)"
21
  [[ -n "$save_key" ]] && tmux bind-key "$save_key" run-shell "$CURRENT_DIR/scripts/_save.sh"
22
23
  local start_action="$(get_opt_start)"
24
  if [[ "$(get_opt_initialized)" == "0" ]]; then
25
    if [[ "$start_action" == "last" ]]; then
26
      tmux run-shell -b "sleep 0.1 && '$CURRENT_DIR/scripts/_restore.sh'"
27
    elif [[ "$start_action" == "pick" ]]; then
28
      tmux run-shell -b "sleep 0.1 && '$CURRENT_DIR/scripts/_pick.sh'"
29
    fi
30
31
    set_opt_initialized "1"
32
  fi
33
34
  add_save_interpolation
35
}
36
main