From aa92dda30746f69d73897429508fde63fa1d03f2 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Sat, 23 Apr 2022 10:27:28 +0200 Subject: [PATCH] add clear example --- README.org | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ examples/clear | 32 ++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100755 examples/clear diff --git a/README.org b/README.org index 3b8a0de..fa5ae64 100644 --- a/README.org +++ b/README.org @@ -166,6 +166,8 @@ echo "${sftbf}${sftr}framework${sftrs}" #+end_src + Look at the [[#clear][clear]] example to see some of them in action. + ** Examples :properties: :custom_id: examples @@ -255,6 +257,66 @@ go #+end_example +*** Clear + :properties: + :custom_id: clear + :end: + + This script shows the usage of color formatting variables and =$sftclr=: + + #+begin_src sh + #!/usr/bin/env bash + + # ---------------------- + # sf -- script framework + # ---------------------- + + # Declare sf variables + sfdesc="Show the usage of color variables and \$sftclr." + + # Include sf, this could be replaced with a long oneliner + source "$(dirname $0)/sf" + + # ---------------------- + # Actual script + # ---------------------- + + echo -n "${sftbf}" # Output everything from here bold + echo "${sftr}These" # Red + sleep 0.5 + echo "${sftm}lines" # Magenta + sleep 0.5 + echo "${sftb}will" # Blue + sleep 0.5 + echo "${sftc}delete" # Cyan + sleep 0.5 + echo "${sftg}themselves" # Green + sleep 1 + echo "${sfty}now!" # Yellow + sleep 0.5 + echo -n "${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}" # Clear six lines + echo "${sftblk}${sftr}T${sftm}a${sftb}d${sftc}a${sftg}a${sfty}!" # Blinking colorful + echo -n "${sftrs}" # Reset text formatting + #+end_src + + The produced usage is: + + #+begin_example + Usage: clear [OPTIONS] + + Show the usage of color variables and $sftclr. + + OPTIONS + -h, --help Show this help message and exit + #+end_example + + The execution results in this: + + #+begin_example + $ ./clear + Tadaa! + #+end_example + *** Add This script adds numbers and shows the usage of =sfparr=: diff --git a/examples/clear b/examples/clear new file mode 100755 index 0000000..ca91b36 --- /dev/null +++ b/examples/clear @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# ---------------------- +# sf -- script framework +# ---------------------- + +# Declare sf variables +sfdesc="Show the usage of color variables and \$sftclr." + +# Include sf, this could be replaced with a long oneliner +source "$(dirname $0)/../sf" + +# ---------------------- +# Actual script +# ---------------------- + +echo -n "${sftbf}" # Output everything from here bold +echo "${sftr}These" # Red +sleep 0.5 +echo "${sftm}lines" # Magenta +sleep 0.5 +echo "${sftb}will" # Blue +sleep 0.5 +echo "${sftc}delete" # Cyan +sleep 0.5 +echo "${sftg}themselves" # Green +sleep 1 +echo "${sfty}now!" # Yellow +sleep 0.5 +echo -n "${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}" # Clear six lines +echo "${sftblk}${sftr}T${sftm}a${sftb}d${sftc}a${sftg}a${sfty}!" # Blinking colorful +echo -n "${sftrs}" # Reset text formatting