use ytfzf history file instead of separate history file

This commit is contained in:
Adithya 2023-08-27 19:08:08 +05:30
parent 70772b26b6
commit 6cdda28f14
Signed by: adtya
GPG key ID: 48FC9915FFD326D0

View file

@ -3,14 +3,14 @@
set -eu
XDG_CACHE_HOME=${XDG_CACHE_HOME:-}
if [ -n "$XDG_CACHE_HOME" ] ; then
HISTORY_FILE="$XDG_CACHE_HOME/youtube_history"
HISTORY_FILE="$XDG_CACHE_HOME/ytfzf/search_hist"
else
HISTORY_FILE="$HOME/.cache/youtube_history"
HISTORY_FILE="$HOME/.cache/ytfzf/search_hist"
fi
if [ ! -e "$HISTORY_FILE" ] ; then
touch "$HISTORY_FILE"
fi
SEARCH_TERM="$(rofi -dmenu -p "Search Youtube:" < "$HISTORY_FILE")"
echo "$SEARCH_TERM" >> $HISTORY_FILE
HISTORY="$(awk -F' ' '{$1="";$2="";$3="";print $0}' $HISTORY_FILE | sed 's/^\s*//g' | uniq)"
SEARCH_TERM="$(echo "$HISTORY" | rofi -dmenu -p "Search Youtube:")"
kitty --class=ytfzf --title "YouTube Search: ${SEARCH_TERM}" -- ytfzf -f -tT kitty --async-thumbnails "${SEARCH_TERM}"