From ba47d8e17dcec9aa0ee1afd945573e8ab97c44c1 Mon Sep 17 00:00:00 2001 From: Daniel Lundin <daniel@arity.se> Date: Thu, 19 Jan 2023 20:53:26 +0100 Subject: [PATCH] tmux-edit-helper: hide common prefix in popup --- bin/tmux-edit-helper | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/tmux-edit-helper b/bin/tmux-edit-helper index f814f45..7ab7bdd 100755 --- a/bin/tmux-edit-helper +++ b/bin/tmux-edit-helper @@ -5,9 +5,10 @@ if [ -n "$1" ]; then _file=$(readlink -f "$@") else FZF=${FZF:-"fzf-tmux -p 90%,50% -y 0"} - _git_root=$(git rev-parse --show-toplevel 2>/dev/null || sl root 2>/dev/null || pwd) - _store=$(echo "$_git_root" | sha1sum | cut -d ' ' -f 1) - _file=$( ( (fre --store_name "$_store" --sorted | xargs -n 100 ls -d 2>/dev/null || true) && fd --type f --hidden --follow --exclude .git --exclude .sl --ignore-file "${_git_root}/.gitignore" . "$_git_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | $FZF --no-sort) + _root=$(git rev-parse --show-toplevel 2>/dev/null || sl root 2>/dev/null || pwd) + _store=$(echo "$_root" | sha1sum | cut -d ' ' -f 1) + _file=$( ( (fre --store_name "$_store" --sorted | xargs -n 100 ls -d 2>/dev/null || true) && fd --type f --hidden --follow --exclude .git --exclude .sl --ignore-file "${_root}/.gitignore" . "$_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | sed -e "s#^${_root}/##" | $FZF --no-sort) + _file="${_root}/${_file}" fre --store_name "$_store" --add "$_file" fi