blob: 7dfb0e9187f952d49ae89fd7e7ca55406e898c3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
# fzf-media: fuzzy search media files
# Useful for browsing video files without having to bother with
# their subtitle files.
export PREVIEW="${PREVIEW:-"cat \"\$(dirname {})/.description/\${\$(basename {})%.*}.txt\" 2>/dev/null || preview {}"}"
find_files() {
filter="${XDG_CONFIG_HOME:-$HOME/.config}/ytignore"
if command -v fd >/dev/null; then
fd -I --color=always --type=file --ignore-file="$filter" . "$@"
else
eval "find $* -type f ! -path '*/.*' $(sed -z "s/\(\S\+\)\n/! -name '\1' /g" "$filter")"
fi
}
[ -z "$FZF_HISTDIR" ] &&
export FZF_HISTDIR="${XDG_STATE_HOME:-$HOME/.local/state}/fzf"
mkdir -pv "$FZF_HISTDIR"
export FZF_HIST="$FZF_HISTDIR/${FMD_HIST_NAME:-media_history}"
find_files "$@" | sort | fzf --multi --reverse --history="$FZF_HIST" \
--header="${FZF_HEADER:-Browse Media Files}" --header-first \
--preview="$PREVIEW" --preview-window=hidden \
--bind 'alt-C:execute(librewolf-open "$(mediainfo --inform="General;%Comment%" {})")' \
--bind 'ctrl-o:execute(append-to-history {q} "$FZF_HIST"; ${OPENER:-xdg-open} {})' \
--bind "alt-3:change-preview($PREVIEW)" \
--bind "alt-@:execute($PREVIEW | yad --text-info)"
|