diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 1dce808..e4b8403 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -13,3 +13,31 @@ map . set hidden! map o $nvim -c "lua require(\"oil\").open(\"$PWD\")" map - $nvim -c "lua require(\"oil\").open(\"$PWD\")" map open + +cmd jump ${{ + FZY_CACHE=~/.cache/fzy_paths + if [ -f $FZY_CACHE ]; then + # Check if cache is older than 1 day + if [ $(($(date +%s) - $(date -r $FZY_CACHE +%s))) -gt 86400 ]; then + rm $FZY_CACHE + fi + fi + if [ ! -f $FZY_CACHE ]; then + PATHS="$(/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME ls-files | xargs -n 1 dirname | uniq | grep -v '^\.$' | parallel echo ~/{})" + search_dirs=(~/Workspace/ \ + /home/server/Storage/Thomas/ \ + ) + for i in $search_dirs ; do + if [ -d $i ]; then + PATHS="$PATHS\n$i" + PATHS="$PATHS\n$(ssh mallorea fdfind . $i -t d -d 8)" + fi + done + echo -e $PATHS > $FZY_CACHE + fi + res="$(cat $FZY_CACHE | fzy -l 20)" + res="$(printf '%s' "$res" | sed 's/\\/\\\\/g;s/"/\\"/g')" + lf -remote "send $id cd \"$res\"" +}} + +map :jump