diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-09-26 15:23:31 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-09-26 15:23:52 -0500 |
commit | abf889cb4887ee81f0dbeaa4c3963d048a8c567e (patch) | |
tree | 57e7782a40241e588b998416634b9864765daeeb /tmux/.local/bin/tmux-sessionizer | |
parent | ef53f32bf9549e5efe2b9b12bd9f387be3ff44c6 (diff) |
feat(tmux): remove tmux sessions from sessionizer
Diffstat (limited to 'tmux/.local/bin/tmux-sessionizer')
-rwxr-xr-x | tmux/.local/bin/tmux-sessionizer | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer index 17599f9..631d154 100755 --- a/tmux/.local/bin/tmux-sessionizer +++ b/tmux/.local/bin/tmux-sessionizer @@ -5,13 +5,10 @@ if [ "$#" -ne 0 ]; then selection="$1" else PROJECT_DIR="$HOME/src" - - if [ -n "$TMUX" ]; then - DIRS="$(tmux list-sessions -F '#{session_last_attached}:#{session_path}' 2>/dev/null | tr -s '\n' ' ' | sed 's/ $//')" - fi + DIRS="$(stat -c %Y:"$HOME/.dotfiles" "$HOME/.dotfiles")" for session in "$XDG_DATA_HOME/nvim/sessions"/*; do - entry="$(printf %s\\n "$session" | sed "s|^$XDG_DATA_HOME/nvim/sessions/||" | sed 's|%%|/|g' | sed 's|__|/|g')" + entry="$(printf %s\\n "$session" | sed "s|^$XDG_DATA_HOME/nvim/sessions/||" | sed 's#%{2}|_{2}#/#g')" if [ -d "$entry" ]; then DIRS="$DIRS $(stat -c %Y:"$entry" "$session")" fi @@ -23,6 +20,10 @@ else fi done + if [ -n "$TMUX" ]; then + attached="$(tmux list-sessions -F '#{?session_attached,#{session_path},}' | sed '/^$/d')" + fi + DIRS="$(printf %s\\n "$DIRS" | xargs -I{} -d ' ' sh -c ' timestamp="$(printf %s "{}" | cut -d":" -f1)" dir_path="$(printf %s "{}" | cut -d":" -f2)" @@ -37,11 +38,10 @@ else else printf %s\\n {} fi - ' | sort -r | sort --field-separator=':' -r --key=2 | uniq -s10 | sort -r | cut -d':' -f2)" + ' | sort -r | sort -t':' -r -k2 | uniq -s10 | sort -r | cut -d':' -f2 | sed "s#^$attached\$##g" | sed '/^$/d')" output="$(printf %s\\n "$DIRS" | fzf-tmux -p -- --print-query -d/ --with-nth -2.. \ - --preview="tmux capture-pane -ep -t \$(basename '{}' | tr . _) 2>/dev/null || - $FZF_PREVIEW_COMMAND || + --preview="$FZF_PREVIEW_COMMAND || printf '%s' {q} | sed 's|/\$||' | xargs hut git show 2>/dev/null || gh repo view {q} 2>/dev/null || printf 'Create new project:\n %s' {q} | |