summaryrefslogtreecommitdiffstatshomepage
path: root/tmux/.local/bin
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-10-18 19:16:50 -0500
committerToby Vincent <tobyv13@gmail.com>2022-10-18 19:16:50 -0500
commit7af166057f9a59fea2eac3a1b26d767ade54ec14 (patch)
tree294014562a6cb3144dfb63ea68dea54866892bf8 /tmux/.local/bin
parenta69bbedfd1f3e5c0eb53aed980de65e4ec6b4d70 (diff)
fix(tmux): fix bug causing fzf-tmux popup to hang
Diffstat (limited to 'tmux/.local/bin')
-rwxr-xr-xtmux/.local/bin/tmux-sessionizer19
1 files changed, 12 insertions, 7 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer
index a440068..7b38dc1 100755
--- a/tmux/.local/bin/tmux-sessionizer
+++ b/tmux/.local/bin/tmux-sessionizer
@@ -1,13 +1,18 @@
#!/bin/sh
# shellcheck disable=2016,2089
-PROJECT_DIR="$HOME/src"
-DOCKER_DIR="$HOME/dkr"
-SESSION_DIR="$XDG_DATA_HOME/nvim/sessions"
-PREVIEW_CMD="([ -n {} ] && less {}) || ([ ! -e {q} ] && less {q})"
-ATTACHED="$(tmux display -p '#{session_path}')"
-
if [ "$#" -eq 0 ]; then
+ PROJECT_DIR="$HOME/src"
+ DOCKER_DIR="$HOME/dkr"
+ SESSION_DIR="$XDG_DATA_HOME/nvim/sessions"
+ PREVIEW_CMD="([ -n {} ] && less {}) || ([ ! -e {q} ] && less {q})"
+
+ ATTACHED=$(tmux display -p '#{session_path}')
+ lines=$(tmux display -p "#{pane_height}")
+ columns=$(tmux display -p "#{pane_width}")
+ WIDTH=$([ "$columns" -gt "120" ] && printf %s "120" || printf %s "90%")
+ HEIGHT=$([ "$lines" -gt "40" ] && printf %s "40" || printf %s "90%")
+
# shellcheck disable=2046
set -- $({
printf %s\\n "$HOME/.dotfiles"
@@ -15,7 +20,7 @@ if [ "$#" -eq 0 ]; then
fd . "$SESSION_DIR" --type=f --max-depth=1 | sed "s|^$SESSION_DIR/||" | sed 's#%%\|__#/#g'
} | sed 's|/$||' | sed "\|^$HOME\$|d" | sed "\|^$ATTACHED\$|d" | sort -u |
timestamp.sh --git --sessions="$SESSION_DIR" --format="{}:{1}" | sort -r | cut -d':' -f2 |
- fzf-tmux -p -- --multi --print-query -d/ --with-nth -1 --preview-window='right,75%,<30(up,30%,border-bottom)' --preview="$PREVIEW_CMD" |
+ fzf-tmux -p "$WIDTH,$HEIGHT" -- --multi --print-query -d/ --with-nth -1 --preview-window='right,75%,<80(up,75%,border-bottom)' --preview="$PREVIEW_CMD" |
tr -s '\n' ' ')
fi