Use fre+fzf to edit any file in a git repo, with frecency history

This commit is contained in:
Daniel Lundin 2022-03-04 12:11:00 +01:00
parent 060fe3fc91
commit 0e80fa3b8f

10
.zshrc
View file

@ -129,7 +129,15 @@ export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
e ()
{
nvr --nostart --remote $(readlink -f "$@")
if [ -n "$1" ]; then
_file=$(readlink -f "$@")
else
_git_root=$(git rev-parse --show-toplevel)
_store=$(printf $_git_root | sha1sum | cut -d ' ' -f 1)
_file=$( (fre --store_name $_store --sorted && fd --type f --hidden --follow --exclude .git . $_git_root) | fzf-tmux)
fre --store_name $_store --add $_file
fi
nvr --nostart --remote $_file
tmux select-window -t1
}