Created
November 9, 2021 18:51
-
-
Save victorekpo/58ab52cc17dc809673bbdc2bed5bd86b to your computer and use it in GitHub Desktop.
Bash x JQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
musicDir=/home/ubuntu/projects/music/music-app | |
#Bash Aliases and Functions | |
alias importMusic="node $musicDir/App.js bulkImport" | |
alias syncMusic="$musicDir/jsontocsv > $musicDir/MUSIC.CSV && php $musicDir/update-musicsheet.php" | |
alias viewMusic="node $musicDir/App.js read" | |
alias trimLines="awk '!NF {if (++n <= 1) print; next}; {n=0;print}'" | |
makeSEDforDel() { cat $musicDir/music.fields | while IFS=, read field; do echo -n 'sed "/\"'$field'\": \"\"/d" |' ; done | sed s/.$//; } | |
makeSEDforLbl() { cat $musicDir/music.fields | while IFS=, read field; do echo -n 'sed "s/'$field'://g" |' ; done | sed s/.$//; } | |
alias createmakeSEDforDel=`makeSEDforDel > $musicDir/tmp/custom.msfd.tmp` | |
alias createmakeSEDforLbl=`makeSEDforLbl > $musicDir/tmp/custom.msfl.tmp` | |
alias runmakeSEDforDel=`cat $musicDir/custom.msfd` | |
alias runmakeSEDforLbl=`cat $musicDir/custom.msfl` | |
searchMusic() { echo -e "\n*******SEARCH RESULTS*******\n"; cat $musicDir/MUSIC.JSON | jq --arg v "${@:2}" '.songs[] | select(.'$1' | match($v;"i"))' | runmakeSEDforDel | tr -d \" | tr -d { | runmakeSEDforLbl | tr -d "," | sed 's/\\//g' | sed "s/;/,/g" | awk NF | tr -d } | trimLines ; echo "`colblue`#djAlgoriddim.V`tput init`" ; } | |
searchSongs() { node $musicDir/App.js filter --all "`echo $@`"; } | |
alias searchmusic=searchMusic | |
searchquotes() { var="${@:1}"; searchMusic quotes "$var" ; } | |
alias searchartist="searchMusic artist" | |
alias searchgenre="searchMusic genre" | |
alias searchtags="searchMusic tags" | |
alias searchalbum="searchMusic album" | |
alias searchspeed="searchMusic speed" | |
alias searchBPM="searchMusic BPM" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment