Files
fuzic/src/sh/fzf.sh
2025-09-11 15:57:06 +02:00

34 lines
1.1 KiB
Bash

# Print the fzf instructions that sets the header
#
# @argument $1: view
# @argument $2: mbid
fzf_command_set_header() {
view=$1
mbid=$2
case "$view" in
"$VIEW_SEARCH_ARTIST") header="Search artist on MusicBrainz" ;;
"$VIEW_SEARCH_ALBUM") header="Search album on MusicBrainz" ;;
"$VIEW_LIST_ARTISTS") header="Search locally available artist" ;;
"$VIEW_LIST_ALBUMS") header="Search locally available album" ;;
"$VIEW_ARTIST")
name="$(mb_artist "$mbid" | $JQ '.name')"
header=$(printf "$ARTIST_PROMPT" "$name")
;;
"$VIEW_RELEASEGROUP")
title="$(mb_releasegroup "$mbid" |
$JQ '.title')"
artist="$(mb_releasegroup "$mbid" |
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
header=$(printf "$FULL_PROMPT" "$artist" "$title")
;;
"$VIEW_RELEASE")
title="$(mb_release "$mbid" |
$JQ '.title')"
artist="$(mb_release "$mbid" |
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
header=$(printf "$FULL_PROMPT" "$artist" "$title")
;;
esac
printf "+change-header(%s)" "${header:-"???"}"
}