Skip to content

Instantly share code, notes, and snippets.

@behrooz-tahanzadeh
Last active August 1, 2017 11:28
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 behrooz-tahanzadeh/bae3ee6ff91a726e9c5bac1632b5025b to your computer and use it in GitHub Desktop.
Save behrooz-tahanzadeh/bae3ee6ff91a726e9c5bac1632b5025b to your computer and use it in GitHub Desktop.
show a prompt listing all files start with __ and run grunt over the selected file
NC='\033[0m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
LIGHT_PURPLE='\033[1;35m'
clear_screen()
{
printf "\ec"
}
align_center()
{
termwidth="$(tput cols)"
padding="$(printf '%0.1s' " "{1..500})"
printf '%*.*s %s %*.*s\n' 0 "$(((termwidth-2-${#1})/2))" "$padding" "$1" 0 "$(((termwidth-1-${#1})/2))" "$padding"
}
hr()
{
eval printf %.0s$1 '{1..'"${COLUMNS:-$(tput cols)}"\}
}
clear_screen
i=0
for f in __*.js
do
files[i]="$f"
files[i+1]=" "
((i+=2))
done
choice=$(whiptail --menu "Please select the file to grunt!?" 14 40 6 "${files[@]}" 3>&1 1>&2 2>&3)
echo -e $LIGHT_PURPLE
hr "ꕹ" && align_center "grunt ${choice}" && hr "ꕹ"
echo -e $NC
grunt $choice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment