tmux-edit-helper: filter out files from history that no longer exist

This commit is contained in:
Daniel Lundin 2023-01-19 12:16:13 +01:00
parent d79ab3f5fd
commit 344508e4c1

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -fe -o pipefail
set -xfe -o pipefail
if [ -n "$1" ]; then
_file=$(readlink -f "$@")
@ -7,7 +7,7 @@ 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 && 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)
_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)
fre --store_name "$_store" --add "$_file"
fi