Last active
January 4, 2022 10:04
-
-
Save ozcanyarimdunya/4a71ad6d94e6170c9cc4839c1a337966 to your computer and use it in GitHub Desktop.
Utility for bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} |
Author
ozcanyarimdunya
commented
Jan 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment