dotfiles/.local/bin/fuz
2024-06-08 09:14:08 +05:00

37 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Populated by fuz-cache script through xprofile at startup
CACHE_DIR="/tmp/fuz_cache"
h_padding=$(printf '%*s' 20 ' ')
h_gap=$(printf '%*s' 4 ' ')
# Define the header using the escape sequences
HEADER="${h_padding}\
 Prefix:Alt${h_gap}\
 1:All/Folders/Git${h_gap}\
 2:Documents${h_gap}\
 3:Images${h_gap}\
 4:Videos"
fzf_main_func() {
cat $CACHE_DIR/all | fzf --ansi --prompt " All  " \
--bind "alt-1:transform:(
([[ \$FZF_PROMPT =~ All ]] && echo 'change-prompt( Folders  )+reload(cat $CACHE_DIR/folders)') ||
([[ \$FZF_PROMPT =~ Folders ]] && echo 'change-prompt( Git  )+reload(cat $CACHE_DIR/git)') ||
echo 'change-prompt( All  )+reload(cat $CACHE_DIR/all)')" \
--bind "alt-2:change-prompt( Documents  )+reload(cat $CACHE_DIR/documents)" \
--bind "alt-3:change-prompt( Images  )+reload(cat $CACHE_DIR/images)" \
--bind "alt-4:change-prompt( Videos  )+reload(cat $CACHE_DIR/videos)" \
--header "$HEADER" \
--height=100% --pointer=" " --ellipsis= --header-first --scheme=path --algo=v2 --color="16" \
--preview-window "bottom,60%,border-top" --border=none --margin=5%,10%,5%,10% --info=inline-right \
--preview "fuz-preview {}"
}
selection=$(fzf_main_func)
if [ -n "$selection" ]; then
fuz-opener "$selection"
fi