mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
* OMB - Major Refactor - Aliases and completions now works like plugins (need to enabled in .bashrc) - Removed the compatible check in spectrum.sh, OMB now works with Bash v3.x like the old days. - Removed core plugin, added those bash functions into base.sh and load during startup. - Updated OSH template for new installations - Added history config and few other stuff from #17 @TODO: Added a shell script to update old version of .bashrc to new one. * Fixed ShellCheck issues * Fixed ShellCheck issues
47 lines
921 B
Bash
47 lines
921 B
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Move a process to background and track its progress in a smoothier way.
|
|
# Could be use if $TERM not set.
|
|
#
|
|
# Examples
|
|
#
|
|
# echo -ne "${fg[red]}I am running..."
|
|
# ( my_long_task_running ) &
|
|
# spinner
|
|
# echo -ne "...${reset_color} ${fg[green]}DONE${reset_color}"
|
|
#
|
|
|
|
# This spinner is used when there is a terminal.
|
|
term_spinner() {
|
|
local pid=$!
|
|
local delay=0.1
|
|
local spinstr='|/-\'
|
|
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
|
local temp=${spinstr#?}
|
|
printf " [%c] " "$spinstr"
|
|
local spinstr=$temp${spinstr%"$temp"}
|
|
sleep $delay
|
|
printf "\b\b\b\b\b\b"
|
|
done
|
|
printf " \b\b\b\b"
|
|
}
|
|
|
|
no_term_spinner() {
|
|
local pid=$!
|
|
local delay=0.1
|
|
local spinstr='|/-\'
|
|
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
|
printf "."
|
|
sleep 2
|
|
done
|
|
echo " ✓ "
|
|
}
|
|
|
|
spinner() {
|
|
if [[ -z "$TERM" ]]; then
|
|
no_term_spinner
|
|
else
|
|
term_spinner
|
|
fi
|
|
}
|