Skip to content

Instantly share code, notes, and snippets.

@ozcanyarimdunya
Last active January 4, 2022 10:04
Show Gist options
  • Save ozcanyarimdunya/4a71ad6d94e6170c9cc4839c1a337966 to your computer and use it in GitHub Desktop.
Save ozcanyarimdunya/4a71ad6d94e6170c9cc4839c1a337966 to your computer and use it in GitHub Desktop.
Utility for bash
#!/usr/bin/env bash
success() {
echo -e "\e[1;32m$1\e[0m"
}
info() {
echo -e "\e[1;34m$1\e[0m"
}
warning() {
echo -e "\e[1;33m$1\e[0m"
}
error() {
echo -e "\e[1;31m$1\e[0m"
}
ask() {
while true; do
read -p "$(success "$1 (y/n) ?") " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
*) error "Please answer y/Y or n/N" ;;
esac
done
}
@ozcanyarimdunya
Copy link
Author

image

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