Advertisement
mosaid

Untitled

Mar 23rd, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #!/bin/bash
  2. file=$(ls -p -1R /path/to/my/Lyrics/directory/ | grep -v /)
  3. str0=$(lsof -F n -c mpv -c clementine|grep -E "^.*\.mp3$|^.*\.mp4$|^.*\.mkv$|^.*\.flv$|^.*\.webm$"| awk -F"/" '{print $NF}')
  4. #str=${str%-*}
  5. str=$(echo "$str0" | sed 's/[^a-zA-Z0-9]/ /g')
  6. echo ""
  7. echo "playing:"
  8. echo "$str0"
  9. echo ""
  10. IFS=', ' read -r -a array <<< "$str"
  11. patterns=$(
  12.     for element in "${array[@]}"
  13.     do
  14.      if [[ ${#element} > 2 ]]
  15.        then
  16.             echo -n "$element|"
  17.      fi
  18.     done
  19. )
  20. patterns=${patterns::-1}
  21. f=$(echo "$file" | awk '{ print NF,$0 }' IGNORECASE=1 FS="$patterns" | sort -nr )
  22. f=$(echo "$f" |head -10 )
  23. nn=$(echo "$f"|awk 'NR==1 {a=$1} NR==2 {b=$1} END {if( a ~ b )print "1"}')
  24. if [[  $nn == 1 ]]
  25.  then
  26.    echo "$f"|cat -n
  27.    read -p " : " answer
  28.    if [[ -z "$answer" ]] ;
  29.     then
  30.         exit
  31.    fi
  32.   else
  33.       answer=1
  34. fi  
  35. ff=$(echo -e "$f"|sed -n "$answer"p |awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}')
  36. fff=$(find  /path/to/my/Lyrics/directory/  -name "$ff")
  37. #echo "$ff"
  38. rr=$(echo "$ff" ; cat "$fff")
  39. #printf "\033[01;36m"
  40. echo "$rr"|less
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement