Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help me with a script

Name: A million pies 2012-02-02 11:54

I want the function "ascii" be updated every second. I also want to be able to terminate the script when I press "q" on the keyboard.
Currently I have this:

#!/bin/bash

function ascii {
    path=$(mpc -f %file% current)
    fullpath=$(echo "/Volumes/My Passport/µziq/"$path)
    dirpath=$(dirname "$fullpath")
    folderpath=$(echo $dirpath"/folder.jpg")
    lines=$(tput lines)
    height=$(echo "$lines-1"|bc)
    width=$(echo "$height*1.87"|bc)
    if [ -f "$folderpath" ]; then
        img2txt -H $height -W $width "$folderpath"
    else
        clear
    fi
}

QQUIT="no"
read -s -t 1 QQUIT
ascii
while [ "$QQUIT" != "q" ];    do
    ascii
    sleep 1
    read -s -t 1 QQUIT
done

However, this does not work entirely as I want. First, the output spams the terminal instead of only showing one dynamic output.
Second, I have to press "return" after I press "q" to terminate.
Any suggestions?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List