Skip to content

Instantly share code, notes, and snippets.

@sydrawat01
Created May 5, 2024 07:30
Show Gist options
  • Select an option

  • Save sydrawat01/73078d12a9c7490921909680715b2004 to your computer and use it in GitHub Desktop.

Select an option

Save sydrawat01/73078d12a9c7490921909680715b2004 to your computer and use it in GitHub Desktop.
Speedtest from the terminal
#!/bin/bash
# Function to display spinner animation
spinner() {
local pid=$!
local delay=0.1
#local spin='|/-\'
local spin='x+'
while ps -p $pid >/dev/null; do
printf "[%c] " "$spin"
spin=${spin#?}${spin%???}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
# Run your command in the background
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | /usr/bin/python3 - --simple &
# Show spinner animation while waiting for output
spinner
# Wait for the command to finish and get its output
wait $!
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment