diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-09-14 15:48:15 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-09-14 15:48:15 -0500 |
commit | 41ab0aa846c140777d380bf07e448a02477e7b9b (patch) | |
tree | 311934c298b5984fda1ba66fe81111a2119b0c37 | |
parent | 1bd0f4b7e95fc8f054115adce62f1a1fd3a6ea7a (diff) |
fix(tmux): remove blankline in sessionizer and fix preview command
-rw-r--r-- | sh/.profile | 4 | ||||
-rwxr-xr-x | tmux/.local/bin/tmux-sessionizer | 38 |
2 files changed, 18 insertions, 24 deletions
diff --git a/sh/.profile b/sh/.profile index 09b8c0b..a24d610 100644 --- a/sh/.profile +++ b/sh/.profile @@ -39,8 +39,8 @@ export FZF_DEFAULT_OPTS='--bind ctrl-q:abort --bind alt-down:half-page-down --color fg:#ebdbb2,hl:#fabd2f,fg+:#ebdbb2,hl+:#fabd2f --color info:#83a598,prompt:#bdae93,spinner:#fabd2f,pointer:#83a598,marker:#fe8019,header:#665c54' -export FZF_PREVIEW_COMMAND='bat --style=numbers,changes --wrap never --color always {} || cat {} || - exa --tree --icons --git-ignore {} || tree -C {}' +export FZF_PREVIEW_COMMAND='bat --style=numbers,changes --wrap never --color always {} 2>/dev/null || cat {} 2>/dev/null || + exa --tree --icons --git-ignore {} 2>/dev/null || tree -C {} 2>/dev/null || printf %s\\n {}' export PATH="$PATH:$HOME/.local/bin" 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)" |