Skip to content

Instantly share code, notes, and snippets.

@chrisshroba
Created July 22, 2015 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisshroba/ab5424d40ac63980c39c to your computer and use it in GitHub Desktop.
Save chrisshroba/ab5424d40ac63980c39c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
COLUMNS=$(tput cols)
echo $COLUMNS
for i in $(seq 0 $((COLUMNS - 2)))
do
echo -ne "\033[2K\r"
echo -n "["
yes = | head -n $i | tr -d "\n"
if [ $((COLUMNS - 2 - i)) != 0 ]
then
yes " " | head -n $((COLUMNS - 2 - i)) | tr -d "\n"
fi
echo -n "]"
sleep .03
done
echo
@bmaca-sprout
Copy link

I am going to suggest double quotes to prevent globbing and word splitting.

echo "$COLUMNS"
| head -n "$i"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment