aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tmux/.local
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-09-14 15:48:15 -0500
committerToby Vincent <tobyv13@gmail.com>2022-09-14 15:48:15 -0500
commit41ab0aa846c140777d380bf07e448a02477e7b9b (patch)
tree311934c298b5984fda1ba66fe81111a2119b0c37 /tmux/.local
parent1bd0f4b7e95fc8f054115adce62f1a1fd3a6ea7a (diff)
fix(tmux): remove blankline in sessionizer and fix preview command
Diffstat (limited to 'tmux/.local')
-rwxr-xr-xtmux/.local/bin/tmux-sessionizer38
1 files changed, 16 insertions, 22 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer
index 5cc162b..87ad760 100755
--- a/tmux/.local/bin/tmux-sessionizer
+++ b/tmux/.local/bin/tmux-sessionizer
@@ -1,39 +1,33 @@
#!/bin/sh
# shellcheck disable=2016
-get_timestamp() {
- path="$1"
- session_file="$XDG_DATA_HOME/nvim/sessions/$(echo "$path" | sed "s|/|%|g").vim"
- if [ -f "$session_file" ]; then
- stat -c %Y:"$path" "$session_file"
- elif git -C "$path" rev-parse HEAD >/dev/null 2>&1; then
- git -C "$path" --no-pager log -1 --all --format="%at:$1" 2>/dev/null
- elif [ -e "$path/.git" ]; then
- stat -c %Y:"$path" "$1"/.git
- else
- stat -c %Y:"$path" "$1"
- fi
-}
-
if [ "$#" -ne 0 ]; then
path="$1"
else
PROJECT_DIR="$HOME/src"
- DIRS="$(get_timestamp "$HOME/.dotfiles")"
- # DIRS="$HOME/.dotfiles"
+ DIRS="$HOME/.dotfiles"
for entry in "$PROJECT_DIR"/*; do
if [ -d "$entry" ]; then
- DIRS="$DIRS $(get_timestamp "$entry")"
- # DIRS="$DIRS $entry"
+ DIRS="$DIRS $entry"
fi
done
- # output="$(echo "$DIRS" | tr -s '[:space:]' '\n' | sort -r | cut -d':' -f2- |
- # fzf-tmux -p -- --print-query -d/ --with-nth -2.. --preview="$FZF_PREVIEW_COMMAND {}")"
+ DIRS="$(printf %s\\n "$DIRS" | xargs -I{} -d ' ' sh -c 'path="{}"
+ session_file="$XDG_DATA_HOME/nvim/sessions/$(echo "$path" | sed "s|/|%|g").vim"
+ if [ -f "$session_file" ]; then
+ stat -c %Y:"$path" "$session_file"
+ elif git -C "$path" rev-parse HEAD >/dev/null 2>&1; then
+ git -C "$path" --no-pager log -1 --all --format="%at:$path" 2>/dev/null
+ elif [ -e "$path/.git" ]; then
+ stat -c %Y:"$path" "$path"/.git
+ else
+ stat -c %Y:"$path" "$path"
+ fi' | sort -r | cut -d':' -f2)"
- output="$(printf %s\\n "$DIRS" | tr -s '[:space:]' '\n' | sort -r | cut -d':' -f2- |
- fzf-tmux -p -- --print-query -d/ --with-nth -2.. --preview="$FZF_PREVIEW_COMMAND {}" | tr -s '\n' ':')"
+ output="$(printf %s\\n "$DIRS" |
+ fzf-tmux -p -- --print-query -d/ --with-nth -2.. --preview="$FZF_PREVIEW_COMMAND {}" |
+ tr -s '\n' ':')"
query="$(printf %s\\n "$output" | cut -d':' -f1)"
selection="$(printf %s\\n "$output" | cut -d':' -f2)"