summaryrefslogtreecommitdiff
path: root/.local/bin/fmd
blob: 72e554267e93c64c90912a6cd405da4c2e5aaf68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

# fzf-media: fuzzy search media files
# Useful when you want to look through a list of video without having to
# bother with their individual supplementary files like subtitles.

export PREVIEW="${PREVIEW:-"cat \"\$(dirname {})/.description/\${\$(basename {})%.*}.txt\" 2>/dev/null || preview {}"}"

fd -I --color=always --type=file --ignore-file="${XDG_CONFIG_HOME:-$HOME/.config}/ytignore" "$@" | sort |
	fzf --multi --reverse \
		--history="${FZF_HIST:=$HOME/.local/share/fzf/media_history}" \
		--header="${FZF_HEADER:-Browse Media Files}" --header-first \
		--preview="$PREVIEW" --preview-window=hidden \
		--bind 'alt-C:execute( ffbrowser "$(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 | less)'