blob: 5dd89a1577190622cbb59da9d86bdfbfcd61b73b (
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
|
#!/bin/sh
if [ "$#" -eq 0 ]; then
GIT_PREVIEW='onefetch --include-hidden {}'
DIR_PREVIEW='tree -CL 3 --gitignore --noreport --filelimit=50 {}'
PREVIEW_CMD="($GIT_PREVIEW || $DIR_PREVIEW) 2>/dev/null"
# shellcheck disable=2046
set -- $(
projectr -mgt ~/dkr ~/pkg ~/src -P ~/.dotfiles --exclude-cwd |
fzf-tmux "$FZF_TMUX_OPTS" -- --tac --select-1 --exit-0 -d/ --with-nth -1 \
--bind 'focus:transform-header(echo {})' \
--preview-window='right,75%,<80(up,75%,border-bottom)' --preview="$PREVIEW_CMD"
)
fi
name=$(basename "$1" | tr . _)
if ! tmux has-session -t="$name" 2>/dev/null; then
tmux new-session -ds "$name" -c "$1"
fi
if [ -z "$TMUX" ] && [ -z "$name" ]; then
tmux attach-session -t "$name"
elif tmux has-session -t="$name" 2>/dev/null; then
tmux switch-client -t "$name"
fi
|