Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active April 17, 2016 22:07
Show Gist options
  • Save chmouel/84d253ef9f9e6f136fa5fe91987ecb94 to your computer and use it in GitHub Desktop.
Save chmouel/84d253ef9f9e6f136fa5fe91987ecb94 to your computer and use it in GitHub Desktop.
#!/bin/bash
while getopts ":l" o; do
case "${o}" in
l)
FROMLAST=yes
;;
esac
done
shift $((OPTIND-1))
if [[ -n $@ ]];then
ARGS=$@
else
ARGS="-fs"
fi
PLAYER=mplayer
PLAYER=mpv
SHUF=shuf
LS=ls
if [[ ${OSTYPE} == darwin* ]];then
SHUF=gshuf
LS=gls
fi
if [[ -n ${FROMLAST} ]];then
FILELISTS=$(${LS} -t -1)
else
FILELISTS=$(${SHUF} -e *)
fi
for v in ${FILELISTS};do
ext=${v##*.}
[[ ${ext} == "sh" || ${ext} == *~ ]] && continue
${PLAYER} ${ARGS} ${v}
[[ -n ${burst} ]] && { sleep 1;continue ;}
read -e -n1 -p "${v}: [B] burst [C] continue [D] Delete [R] random [Q] quit Others continue: " A
case ${A} in
c|C)
continue
;;
l|L)
mpv ${ARGS} ${v}
continue
;;
b|B)
burst=yes
;;
D)
echo ${v} is going to be deleted
sleep 2
rm -vf ${v}
continue
;;
q|Q)
exit
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment