Skip to content

Instantly share code, notes, and snippets.

@paulera
Last active November 16, 2020 11:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulera/a96d8a302f654ef6d6bf688732fc7daa to your computer and use it in GitHub Desktop.
Save paulera/a96d8a302f654ef6d6bf688732fc7daa to your computer and use it in GitHub Desktop.
Pretend your terminal is doing techy things

Fake process script

Simulates a build/configuration/installation-like process, using a random message with a nice fake progress, with percentage, random total and variable pace. The command does it as many times and as fast as you set in 2 first variables (maxsteps and pace). Goes really well with a cup of coffee! ;)

  • maxsteps = number of steps to run until "finish".
  • pace = step increment speed. Lower numbers are faster. 500 works well.
  • Arrays a, b and c = word lists. change them as you like, words separated by space.

Minified version (for quick procrastination)

clear; maxsteps=88; pace=500; a=( Tracking Updating Building Compiling Analyzing Saving Optimizing Scanning Checking Loading ); b=( system downloaded core hidden indexed compressed obfuscated scheduled default binary ); c=( files resources dependencies folders socket packages entries library list drivers ); j=0; while (( j < maxsteps )); do ((j++)); echo -n "$j) ${a[$[$RANDOM % ${#a[@]} ]]} ${b[$[$RANDOM % ${#b[@]} ]]} ${c[$[$RANDOM % ${#c[@]} ]]} "; total=$(( 20 + ($RANDOM % 150) )); for i in $(seq 0 $total); do ii="   "$((100*i/total)); echo -n -e ". > [${ii:(-2)}%]\b\b\b\b\b\b\b\b"; s=000$(($RANDOM % pace)); sleep 0.${s:(-3)}; done; echo " ok!     "; done; echo -n -e "\nFinished\n\n";

Expanded version (for scripting)

#!/bin/sh

# Simulates a build/configuration/installation-like process, using a
# random message with a nice fake progress, with percentage, random total
# and variable pace. The command does it as many times and as fast as you
# set in 2 first variables (maxsteps and pace). Goes really well with a
# cup of coffee! ;)
#
# https://gist.github.com/paulera/a96d8a302f654ef6d6bf688732fc7daa
# by Paulo Amaral

clear;

# set behaviour
maxsteps=88;
pace=500;

# word lists
a=( Tracking Updating Building Compiling Analyzing Saving Optimizing Scanning Checking Loading );
b=( system downloaded core hidden indexed compressed obfuscated scheduled default binary );
c=( files resources dependencies folders socket packages entries library list drivers );

j=0;
while (( j < maxsteps )); do

	((j++));

	echo -n "$j) ${a[$[$RANDOM % ${#a[@]} ]]} ${b[$[$RANDOM % ${#b[@]} ]]} ${c[$[$RANDOM % ${#c[@]} ]]} ";

	# total = number of increments for this step
	total=$(( 20 + ($RANDOM % 150) ));
	
	# progess bar from 0% to 100%
	for i in $(seq 0 $total); do
	
		ii="   "$((100*i/total));
		echo -n -e ". > [${ii:(-2)}%]\b\b\b\b\b\b\b\b";
		# sleep a random interval for that organic touch
		s=000$(($RANDOM % pace));
		sleep 0.${s:(-3)};
		
	done;
	echo " ok!     ";
	
done;
echo -n -e "\nFinished\n\n";

Output looks like...

1) Scanning indexed socket ............................................. ok!
2) Optimizing scheduled folders ....................................................................................................................................................................... ok!
3) Building system files ........................................................................... ok!
4) Compiling binary resources ....................................................... ok!
5) Checking scheduled files .................................................................................................................................................................. ok!
6) Scanning scheduled dependencies .................................................................... ok!
7) Saving indexed dependencies .................................................................................... ok!
8) Loading obfuscated list ................................... ok!
9) Analyzing indexed socket ............ ok!
10) Updating default library .............................................................................................................................................. ok!
11) Building scheduled drivers ............................................................... ok!
12) Optimizing binary dependencies ......................... ok!
13) Optimizing system entries .............................................................................................................................................................. ok!
14) Optimizing binary library .................. > [20%]

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