summaryrefslogtreecommitdiff
path: root/ar/.local/bin/sessionizer
blob: 93f32b139096653be56c0c7d4c2e8ccaddbcf5b6 (plain)
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
31
32
33
34
35
36
#!/bin/sh

sessionizer() {
  path="$(
    sesh list -d --icons | fzf-tmux \
      -p 80%,70% --no-sort --cycle --ignore-case --ansi --border=sharp --multi --reverse \
      --border-label "╢ TheSiahxyz ╟" \
      --header "^a all ^e sesh ^f zoxide ^g git ^t tmux ^u staged files ^x tmux kill M-cr open in editor ^/ help" \
      --prompt "💡  " \
      --bind "ctrl-a:change-prompt(💡  )+reload(sesh list -d -H --icons)" \
      --bind "ctrl-e:change-prompt(📑  )+reload(sesh list -d -c -H --icons)" \
      --bind "ctrl-f:change-prompt(🔎  )+reload(sesh list -d -z -H --icons)" \
      --bind "ctrl-g:change-prompt(  )+reload(fd -H -d 1 -d -t d -E .Trash -E .git -E .cache . $HOME/Private/repos $HOME/Public/repos | sed 's|$HOME|~|g')" \
      --bind "ctrl-t:change-prompt(🪟  )+reload(sesh list -d -t --icons)" \
      --bind "ctrl-v:execute($EDITOR ${0})+abort" \
      --bind 'ctrl-x:execute(tmux kill-session -t "$(echo {} | cut -d" " -f2-)")+reload(sesh list -d --icons)' \
      --bind "alt-enter:execute($EDITOR {})+abort" \
      --bind 'ctrl-/:change-prompt(❓  )+reload(echo "^a all
^e sesh config
^f zoxide
^g git
^t tmux
^x tmux kill
M-cr open in editor
^/ help")' \
      --preview-window 'right:45%' \
      --preview 'sesh preview {}'
  )" 2>/dev/null

  case "$path" in
  ^*) sessionizer ;;
  *) sesh connect "$path" >/dev/null 2>&1 && exit ;;
  esac
}

sessionizer