aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tmux/.local
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2023-05-08 17:30:20 -0500
committerToby Vincent <tobyv13@gmail.com>2023-05-08 17:33:23 -0500
commit595e4f152ad1c1378c022dbbb156ef7804835b3d (patch)
tree1e3f0f4190a94315647af88de79cbbf35be5168e /tmux/.local
parent789c7c1eb7655fdb33868fecf9ea56477a14c8b6 (diff)
refactor(tmux): simplify sessionizer script
Signed-off-by: Toby Vincent <tobyv13@gmail.com>
Diffstat (limited to 'tmux/.local')
-rwxr-xr-xtmux/.local/bin/tmux-sessionizer43
-rwxr-xr-xtmux/.local/bin/tmux-sessions4
2 files changed, 10 insertions, 37 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer
index 110ef63..f102420 100755
--- a/tmux/.local/bin/tmux-sessionizer
+++ b/tmux/.local/bin/tmux-sessionizer
@@ -1,47 +1,24 @@
#!/bin/sh
-# shellcheck disable=2016,2089
if [ "$#" -eq 0 ]; then
- PREVIEW_CMD='sel={}; less ${sel:-{q}} 2>/dev/null'
+ GIT_PREVIEW='onefetch --include-hidden'
+ DIR_PREVIEW='exa --tree --git-ignore --level=3 --icons'
+ 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 --multi --print-query -d/ --with-nth -1 \
+ 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" |
- tr -s '\n' ' '
- ) && [ $# -gt 1 ] && shift
+ --preview-window='right,75%,<80(up,75%,border-bottom)' --preview="$PREVIEW_CMD"
+ )
fi
-while [ $# -gt 0 ]; do
- session_path="$1"
- shift
+name=$(basename "$1" | tr . _)
- if [ ! -d "$session_path" ]; then
- repo="$session_path"
- if [ "$repo" = "${repo%/*}/${repo#*/}" ]; then
- for remote in ${GIT_REMOTES:-https://git.sr.ht https://github.com}; do
- if git ls-remote "$remote/$repo" CHECK_GIT_REMOTE_REACHABILITY; then
- session_path="$remote/$repo"
- break
- fi
- done
- fi
-
- session_path="$HOME/src/$(basename "$session_path")"
- git clone "$repo" "$session_path"
- fi
-
- if [ ! -d "$session_path" ]; then
- continue
- fi
-
- name=$(basename "$session_path" | tr . _)
- if ! tmux has-session -t="$name" 2>/dev/null; then
- tmux new-session -ds "$name" -c "$session_path"
- fi
-done
+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"
diff --git a/tmux/.local/bin/tmux-sessions b/tmux/.local/bin/tmux-sessions
index ebad2af..c9333dc 100755
--- a/tmux/.local/bin/tmux-sessions
+++ b/tmux/.local/bin/tmux-sessions
@@ -12,10 +12,6 @@ if [ "$#" -eq 0 ]; then
)
fi
-if [ "$#" -eq 0 ]; then
- exit 0
-fi
-
if [ -z "$TMUX" ]; then
tmux attach-session -t "$1"
else