Created
December 14, 2011 22:13
-
-
Save alexsancho/1478807 to your computer and use it in GitHub Desktop.
Revisions
-
alexsancho revised this gist
Dec 14, 2011 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -70,10 +70,8 @@ function _main_() esac done if [[ $growl && $(which growlnotify) ]]; then growlnotify "$title" --appIcon "Terminal" --message "$response" else echo -e$newline $response fi -
alexsancho revised this gist
Dec 14, 2011 . 1 changed file with 61 additions and 62 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,81 +5,80 @@ # Version: 1.0 # Date: 18.10.2011 # Author: (c) by Alex Sancho - <alex@alexsancho.name> # # Notes: Display a message. ##################################################################### function usage() { prname=$(basename $0) log "$prname: Display a message." log "Usage: $prname [-s] [-e] [-w] [-n] [-g] [-t] <string>" log "Examp: $prname -w \"this is a warning!!\"" log "Options:" log " $prname [-s] displays a success message" log " $prname -e displays an error message" log " $prname -w displays a warning message" log " $prname -n displays a warning message using -n as an echo argument" log " $prname -g displays a message using growlnotify" log " $prname -t sets the title of growl alert" } function _main_() { local response="" newline="" growl="" title="" [[ -n 1 ]] || return 0; if [[ $# -eq 1 ]]; then response="\033[00;37m$1\033[00m" fi while getopts ":s:e:w:g:t:nh[-help]:" optname do case "$optname" in h | -help) usage exit 0 ;; s) response="\033[00;32m$OPTARG\033[00m" ;; e) response="\033[00;31m$OPTARG\033[00m" ;; w) response="\033[0;35m$OPTARG\033[00m" ;; n) newline=n ;; t) title="$OPTARG" ;; g) growl=1 response="$OPTARG" ;; \?) $0 -w "Invalid option: -$OPTARG" >&2 ;; :) $0 -e "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done if [[ $growl ]]; then if [[ $(which growlnotify) ]]; then growlnotify "$title" --appIcon "Terminal" --message "$response" fi else echo -e$newline $response fi return 0 } ## Run script... -
alexsancho renamed this gist
Dec 14, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
alexsancho created this gist
Dec 14, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,86 @@ #!/usr/bin/env bash ##################################################################### # Program: log ##################################################################### # Version: 1.0 # Date: 18.10.2011 # Author: (c) by Alex Sancho - <alex@alexsancho.name> # # Notes: Display a message. ##################################################################### function usage() { prname=$(basename $0) log "$prname: Move filenames to lowercase" log "Usage: $prname [-s] [-e] [-w] [-n] [-g] [-t] <string>" log "Examp: $prname -w \"this is a warning!!\"" log "Options:" log " $prname [-s] displays a success message" log " $prname -e displays an error message" log " $prname -w displays a warning message" log " $prname -n displays a warning message using -n as an echo argument" log " $prname -g displays a message using growlnotify" log " $prname -t sets the title of growl alert" } function _main_() { local response="" newline="" growl="" title="" [[ -n 1 ]] || return 0; if [[ $# -eq 1 ]]; then response="\033[00;37m$1\033[00m" fi while getopts ":s:e:w:n:g:t:h[-help]:" optname do case "$optname" in h | -help) usage exit 2 ;; s) response="\033[00;32m$OPTARG\033[00m" ;; e) response="\033[00;31m$OPTARG\033[00m" ;; w) response="\033[0;35m$OPTARG\033[00m" ;; n) response="\033[00;37m$OPTARG\033[00m" newline=n ;; t) title="$OPTARG" ;; g) growl=1 response="$OPTARG" ;; \?) $0 -w "Invalid option: -$OPTARG" >&2 ;; :) $0 -e "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done if [[ $growl ]]; then if [[ $(which growlnotify) ]]; then growlnotify "$title" --appIcon "Terminal" --message "$response" fi else echo -e$newline $response fi return 0 } ## Run script... _main_ "$@"