From 6b23ff0725d7c92599c9ca03f5ab3e3450529581 Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Sat, 21 Jul 2018 20:57:53 +0200 Subject: [PATCH 1/9] Added helper to check if the script is loaded correctly --- ok.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ok.sh b/ok.sh index abde7b0..e1f5ec6 100755 --- a/ok.sh +++ b/ok.sh @@ -1,6 +1,12 @@ #!/usr/bin/env bash -# tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". ~/path/to/ok-bash/ok.sh" +called=$_ + +#basically, get the absolute path of this script (handy for loads of things) +pushd "$(dirname "${BASH_SOURCE[@]}")" > /dev/null; +_OK_PATH_TO_ME=$(pwd) +popd > /dev/null; + ok() { function _ok_cmd_usage { @@ -31,7 +37,8 @@ script-arguments: _OK_C_PROMPT ${_OK_C_PROMPT}Color-code${C_NC} for prompt (both input as command confirmation). Defaults to color for numbering. environment variables (other): _OK_PROMPT String ($p) used as prompt (both input as command confirmation). Defaults to '$ '. - _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet.\n" + _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet. + _OK_PATH_TO_ME The path ($_OK_PATH_TO_ME) to the location of this script (for internal use).\n" fi if [[ -n $1 ]]; then echo -e "$1\n" @@ -153,3 +160,9 @@ environment variables (other): fi fi } + +if [[ $called == $0 ]]; then + # tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". ~/path/to/ok-bash/ok.sh" + echo 'tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". '${_OK_PATH_TO_ME}'/ok.sh"' +fi +unset called From 137bbc1eb67a79d210becf2a971ef84d665c7bf6 Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Sat, 21 Jul 2018 21:31:25 +0200 Subject: [PATCH 2/9] Made 'list' default again and configurable --- .ok | 7 ++++--- ok.sh | 49 +++++++++++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/.ok b/.ok index 5ef540b..a33aaf1 100644 --- a/.ok +++ b/.ok @@ -3,11 +3,12 @@ unset _OK_C_HEADING;unset _OK_C_NUMBER;unset _OK_C_COMMENT;unset _OK_C_COMMAND;u _OK_C_HEADING="[h]";_OK_C_NUMBER="[n]";_OK_C_COMMENT="[--]";_OK_C_COMMAND="[C]";_OK_C_PROMPT="[p]" #Change colors to text markers for debugging _OK_C_HEADING=$'\033[1;30;45m';_OK_C_NUMBER=$'\033[1;33;44m ';_OK_C_COMMENT=$'\033[1;34;46m';_OK_C_COMMAND=$'\033[1;37;44m' #Custom color scheme # Other customizations -unset _OK_PROMPT; unset _OK_VERBOSE # Reset to defaults -_OK_PROMPT="-=> "; _OK_VERBOSE=2 # Show a "nice" prompt, and give all the feedback ok can provide for -_OK_PROMPT="% "; _OK_VERBOSE=0 # Show ancient prompt, and only say the most necessary (don't even show executed command) +unset _OK_PROMPT; unset _OK_VERBOSE; unset _OK_LIST_PROMPT # Reset to defaults +_OK_PROMPT="-=> "; _OK_VERBOSE=2; _OK_LIST_PROMPT=1 # Show a "nice" prompt, and give all the feedback ok can provide for, and default list'n'prompt +_OK_PROMPT="% "; _OK_VERBOSE=0; _OK_LIST_PROMPT=0 # Show ancient prompt, and only say the most necessary (don't even show executed command) # Tests arguments passing (you can pass arguments after , both at the bash-prompt and the ok-prompt) echo "Passed arguments: 1:[$1], 2:[$2], 3:[$3], 4+:[${@:4}] (nr args: $#)" # Comment-color starts too early; clearly a bug (so better echo "All passed arguments: [$@]" # not to use a number sign in a command for now)... ok help --verbose # Show help page of 🆗, including environment variables +set | grep "^_OK_" # Show all set environment variables, used with ok-bash diff --git a/ok.sh b/ok.sh index e1f5ec6..81ec8eb 100755 --- a/ok.sh +++ b/ok.sh @@ -11,34 +11,43 @@ popd > /dev/null; ok() { function _ok_cmd_usage { unset -f _ok_cmd_usage #emulate a "local" function + if [[ $show_prompt == 1 ]]; then + local list_default="" list_prompt_default=" Default command." + else + local list_default=" Default command." list_prompt_default="" + fi echo -e "Usage: ok [options] [script-arguments..] ok command [options] command (use one): - Run the th command from the '.ok' file. - l, list Show the list from the '.ok' file. - L, list-once Same as list, but only show when pwd is different from when the list was last shown. - p, list-prompt Show the list and wait for input at the ok-prompt (like --list and in one command). Default command. - h, help Show this usage page. + Run the th command from the '.ok' file. + l, list Show the list from the '.ok' file.$list_default + L, list-once Same as list, but only show when pwd is different from when the list was last shown. + p, list-prompt Show the list and wait for input at the ok-prompt (like --list and in one command).$list_prompt_default + h, help Show this usage page. options: - -v, --verbose Show more output, most of the time to stderr. - -q, --quiet Only show really necessary output. + -v, --verbose Show more output, most of the time to stderr. + -q, --quiet Only show really necessary output. script-arguments: - ... These are passed through, when a line is executed (you can enter these too at the ok-prompt)\n" + ... These are passed through, when a line is executed (you can enter these too at the ok-prompt)\n" if [[ $verbose -ge 2 ]]; then - if [ -z ${_OK_PROMPT+x} ]; then local p="unset"; else local p="'$_OK_PROMPT'"; fi - if [ -z ${_OK_VERBOSE+x} ]; then local v="unset"; else local v="'$_OK_VERBOSE'"; fi + if [ -z ${_OK_PROMPT+x} ]; then local p="unset"; else local p="'$_OK_PROMPT'"; fi + if [ -z ${_OK_VERBOSE+x} ]; then local v="unset"; else local v="$_OK_VERBOSE"; fi + if [ -z ${_OK_PROMPT_DEFAULT+x} ]; then local l="unset"; else local l="$_OK_PROMPT_DEFAULT"; fi echo -e "environment variables (used for colored output; current colors are shown): - _OK_C_HEADING ${_OK_C_HEADING}Color-code${C_NC} for lines starting with a comment (heading). Defaults to red. - _OK_C_NUMBER ${_OK_C_NUMBER}Color-code${C_NC} for numbering. Defaults to cyan. - _OK_C_COMMENT ${_OK_C_COMMENT}Color-code${C_NC} for comments after commands. Defaults to blue. - _OK_C_COMMAND ${_OK_C_COMMAND}Color-code${C_NC} for commands. Defaults to color-reset. - _OK_C_PROMPT ${_OK_C_PROMPT}Color-code${C_NC} for prompt (both input as command confirmation). Defaults to color for numbering. -environment variables (other): - _OK_PROMPT String ($p) used as prompt (both input as command confirmation). Defaults to '$ '. - _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet. - _OK_PATH_TO_ME The path ($_OK_PATH_TO_ME) to the location of this script (for internal use).\n" + _OK_C_HEADING ${_OK_C_HEADING}Color-code${C_NC} for lines starting with a comment (heading). Defaults to red. + _OK_C_NUMBER ${_OK_C_NUMBER}Color-code${C_NC} for numbering. Defaults to cyan. + _OK_C_COMMENT ${_OK_C_COMMENT}Color-code${C_NC} for comments after commands. Defaults to blue. + _OK_C_COMMAND ${_OK_C_COMMAND}Color-code${C_NC} for commands. Defaults to color-reset. + _OK_C_PROMPT ${_OK_C_PROMPT}Color-code${C_NC} for prompt (both input as command confirmation). Defaults to color for numbering. +environment variables (other configuration): + _OK_PROMPT String ($p) used as prompt (both input as command confirmation). Defaults to '$ '. + _OK_PROMPT_DEFAULT Setting ($l) if the prompt is default shown. 1=use command list-prompt when issuing no command, otherwise use list. + _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet. +environment variables (for internal use): + _OK_LAST_PWD Remember the path ($_OK_LAST_PWD) that was last listed, for use with the list-once command. + _OK_PATH_TO_ME The path ($_OK_PATH_TO_ME) to the location of this script.\n" fi if [[ -n $1 ]]; then echo -e "$1\n" @@ -100,7 +109,7 @@ environment variables (other): local cmd=list local line_nr=0 local once_check=0 - local show_prompt=1 + local show_prompt=${_OK_PROMPT_DEFAULT} local usage_error= local loop_args=1 #the Pascal-way to break loops while (( $# > 0 && $loop_args == 1 )) ; do From 7b50c9f402f7a2f24dd78b43426d5941916770ad Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Sat, 21 Jul 2018 21:54:15 +0200 Subject: [PATCH 3/9] Numbers are now right aligned --- .ok | 19 ++++++++++--------- ok.sh | 22 +++++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.ok b/.ok index a33aaf1..bbc2283 100644 --- a/.ok +++ b/.ok @@ -1,14 +1,15 @@ -# Manipulate customizations (colors) +# Manipulate customizations (colors) unset _OK_C_HEADING;unset _OK_C_NUMBER;unset _OK_C_COMMENT;unset _OK_C_COMMAND;unset _OK_C_PROMPT #Reset colors to defaults _OK_C_HEADING="[h]";_OK_C_NUMBER="[n]";_OK_C_COMMENT="[--]";_OK_C_COMMAND="[C]";_OK_C_PROMPT="[p]" #Change colors to text markers for debugging _OK_C_HEADING=$'\033[1;30;45m';_OK_C_NUMBER=$'\033[1;33;44m ';_OK_C_COMMENT=$'\033[1;34;46m';_OK_C_COMMAND=$'\033[1;37;44m' #Custom color scheme -# Other customizations +# Other customizations unset _OK_PROMPT; unset _OK_VERBOSE; unset _OK_LIST_PROMPT # Reset to defaults -_OK_PROMPT="-=> "; _OK_VERBOSE=2; _OK_LIST_PROMPT=1 # Show a "nice" prompt, and give all the feedback ok can provide for, and default list'n'prompt -_OK_PROMPT="% "; _OK_VERBOSE=0; _OK_LIST_PROMPT=0 # Show ancient prompt, and only say the most necessary (don't even show executed command) +_OK_PROMPT="-=> "; _OK_VERBOSE=2; _OK_PROMPT_DEFAULT=1 # Show a "nice" prompt, and give all the feedback ok can provide for, and default list'n'prompt +_OK_PROMPT="% "; _OK_VERBOSE=0; _OK_PROMPT_DEFAULT=0 # Show ancient prompt, and only say the most necessary (don't even show executed command) -# Tests arguments passing (you can pass arguments after , both at the bash-prompt and the ok-prompt) -echo "Passed arguments: 1:[$1], 2:[$2], 3:[$3], 4+:[${@:4}] (nr args: $#)" # Comment-color starts too early; clearly a bug (so better -echo "All passed arguments: [$@]" # not to use a number sign in a command for now)... -ok help --verbose # Show help page of 🆗, including environment variables -set | grep "^_OK_" # Show all set environment variables, used with ok-bash +# Tests arguments passing (you can pass arguments after , both at the bash-prompt and the ok-prompt) +echo "Passed arguments: 1:[$1], 2:[$2], 3:[$3], 4+:[${@:4}] (nr args: $#)" # Comment-color starts too early; clearly a bug (so better +echo "All passed arguments: [$@]" # not to use a number sign in a command for now)... + +ok help --verbose # Show help page of 🆗, including environment variables +set | grep "^_OK_" # Show all set environment variables, used with ok-bash diff --git a/ok.sh b/ok.sh index 81ec8eb..0ffc845 100755 --- a/ok.sh +++ b/ok.sh @@ -4,7 +4,7 @@ called=$_ #basically, get the absolute path of this script (handy for loads of things) pushd "$(dirname "${BASH_SOURCE[@]}")" > /dev/null; -_OK_PATH_TO_ME=$(pwd) +_OK__PATH_TO_ME=$(pwd) popd > /dev/null; @@ -46,8 +46,8 @@ environment variables (other configuration): _OK_PROMPT_DEFAULT Setting ($l) if the prompt is default shown. 1=use command list-prompt when issuing no command, otherwise use list. _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet. environment variables (for internal use): - _OK_LAST_PWD Remember the path ($_OK_LAST_PWD) that was last listed, for use with the list-once command. - _OK_PATH_TO_ME The path ($_OK_PATH_TO_ME) to the location of this script.\n" + _OK__LAST_PWD Remember the path ($_OK_LAST_PWD) that was last listed, for use with the list-once command. + _OK__PATH_TO_ME The path ($_OK__PATH_TO_ME) to the location of this script.\n" fi if [[ -n $1 ]]; then echo -e "$1\n" @@ -79,9 +79,12 @@ environment variables (for internal use): function _ok_cmd_list { unset -f _ok_cmd_list + # determine number of command lines (need to trim on macOS) + nr_lines=$(cat .ok | egrep "^[^#]" | wc -l | sed 's/^[ \t]*//') + # list the content of the file, with a number (1-based) before each line, # except lines starting with a "#", those are printed red without a number) as headers - cat .ok | awk -v h="$C_HEADING" -v n="$C_NUMBER" -v c="$C_COMMENT" -v m="$C_COMMAND" -v x="$C_NC" $' + cat .ok | awk -v h="$C_HEADING" -v n="$C_NUMBER" -v c="$C_COMMENT" -v m="$C_COMMAND" -v x="$C_NC" -v P="${#nr_lines}" $' $0 ~ /^(#|$)/ { #print the (sub-)headings and/or empty lines print x h $0 x; @@ -89,7 +92,8 @@ environment variables (for internal use): $0 ~ /^[^#]/ { #print the commands sub(/#/,c "#"); - print x n "" ++i "." m " " $0 x; + NR = sprintf("%" P "d.", ++i); + print x n NR m " " $0 x; }' } @@ -140,7 +144,7 @@ environment variables (for internal use): if [[ $cmd == run ]]; then _ok_cmd_run $line_nr "$@" || return $? elif [[ $cmd == list ]]; then - if [[ $once_check == 0 || ($once_check == 1 && $_OK_LAST_PWD != $(pwd)) ]]; then + if [[ $once_check == 0 || ($once_check == 1 && $_OK__LAST_PWD != $(pwd)) ]]; then _ok_cmd_list || return $? if [[ $show_prompt == 1 ]]; then local prompt_input @@ -156,10 +160,10 @@ environment variables (for internal use): fi fi fi - if [[ $verbose -ge 2 && $once_check == 1 && $_OK_LAST_PWD == $(pwd) ]]; then + if [[ $verbose -ge 2 && $once_check == 1 && $_OK__LAST_PWD == $(pwd) ]]; then echo "The listing for this folder has already been shown" fi - export _OK_LAST_PWD=$(pwd) + export _OK__LAST_PWD=$(pwd) elif [[ $cmd == usage ]]; then _ok_cmd_usage "$usage_error" || return $? fi @@ -172,6 +176,6 @@ environment variables (for internal use): if [[ $called == $0 ]]; then # tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". ~/path/to/ok-bash/ok.sh" - echo 'tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". '${_OK_PATH_TO_ME}'/ok.sh"' + echo 'tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". '${_OK__PATH_TO_ME}'/ok.sh"' fi unset called From 695659273e22fd3646d9c54946d8b784cbca7eae Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Sat, 21 Jul 2018 21:59:02 +0200 Subject: [PATCH 4/9] Made internal variables follow `_OK__` naming scheme well, completed it with this commit. --- ok.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ok.sh b/ok.sh index 0ffc845..611e70d 100755 --- a/ok.sh +++ b/ok.sh @@ -46,7 +46,7 @@ environment variables (other configuration): _OK_PROMPT_DEFAULT Setting ($l) if the prompt is default shown. 1=use command list-prompt when issuing no command, otherwise use list. _OK_VERBOSE Level ($v) of feedback ok provides. 0=quiet, 1=normal, 2=verbose. Defaults to 1. Can be overriden with --verbose or --quiet. environment variables (for internal use): - _OK__LAST_PWD Remember the path ($_OK_LAST_PWD) that was last listed, for use with the list-once command. + _OK__LAST_PWD Remember the path ($_OK__LAST_PWD) that was last listed, for use with the list-once command. _OK__PATH_TO_ME The path ($_OK__PATH_TO_ME) to the location of this script.\n" fi if [[ -n $1 ]]; then From b7fc8fab777258f6737b41448d13322b2283dd0d Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Sun, 22 Jul 2018 22:22:04 +0200 Subject: [PATCH 5/9] Now works when loading from .bashrc too --- ok.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ok.sh b/ok.sh index 611e70d..cbfad69 100755 --- a/ok.sh +++ b/ok.sh @@ -3,7 +3,7 @@ called=$_ #basically, get the absolute path of this script (handy for loads of things) -pushd "$(dirname "${BASH_SOURCE[@]}")" > /dev/null; +pushd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null; _OK__PATH_TO_ME=$(pwd) popd > /dev/null; From 5d62a94009878fe049b247169e24485d526e0689 Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Thu, 26 Jul 2018 15:56:48 +0200 Subject: [PATCH 6/9] Save prompt input to history, when used --- ok.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ok.sh b/ok.sh index cbfad69..cdf938f 100755 --- a/ok.sh +++ b/ok.sh @@ -108,7 +108,8 @@ environment variables (for internal use): if [ -z ${_OK_PROMPT+x} ]; then local PROMPT="$ "; else local PROMPT=$_OK_PROMPT; fi if [ -z ${_OK_VERBOSE+x} ]; then local verbose=1; else local verbose=$_OK_VERBOSE; fi - # handle command line arguments first + # handle command line arguments now + local args="ok $@" #preserve all arguments ($0 is '-bash', so hard-code function name) local re_is_num='^[1-9][0-9]*$' #numbers starting with "0" would be octal, and nobody knows those (also: sed on Linux complains about line "0")... local cmd=list local line_nr=0 @@ -151,6 +152,9 @@ environment variables (for internal use): local re_num_begin='^[1-9][0-9]*($| )' # You can enter arguments at the ok-prompt too, hence different regex read -p "${C_PROMPT}${PROMPT}${C_NC}" prompt_input if [[ $prompt_input =~ $re_num_begin ]]; then + #save command to history first + history -s $args $prompt_input + #execute command eval _ok_cmd_run $prompt_input || return $? else if [[ $verbose -ge 2 ]]; then From 639ae606f31fbc898d2a103dda4cd16176f380d2 Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Thu, 26 Jul 2018 18:53:18 +0200 Subject: [PATCH 7/9] Added some installation helpers --- ok.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ok.sh b/ok.sh index cdf938f..eda14ec 100755 --- a/ok.sh +++ b/ok.sh @@ -181,5 +181,20 @@ environment variables (for internal use): if [[ $called == $0 ]]; then # tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". ~/path/to/ok-bash/ok.sh" echo 'tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". '${_OK__PATH_TO_ME}'/ok.sh"' +else + # Reset all used environment variables + unset _OK_C_HEADING; unset _OK_C_NUMBER; unset _OK_C_COMMENT; unset _OK_C_COMMAND; unset _OK_C_PROMPT + unset _OK_PROMPT; unset _OK_PROMPT_DEFAULT; unset _OK_VERBOSE; unset _OK__LAST_PWD + # Process some installation helpers + while (( $# > 0 )) ; do + case $1 in + prompt) if [[ $# -ge 2 ]]; then export _OK_PROMPT=$2; shift; else echo "the prompt argument needs the actual prompt as 2nd argument"; fi;; + prompt_default) export _OK_PROMPT_DEFAULT=1;; + verbose) export _OK_VERBOSE=2;; + quiet) export _OK_VERBOSE=0;; + *) echo "Ignoring unknown argument '$1'";; + esac + shift + done fi unset called From 571abcd1249129221d30c741e5cbbacb31c408e0 Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Thu, 26 Jul 2018 19:05:08 +0200 Subject: [PATCH 8/9] Added help for installation helpers --- ok.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ok.sh b/ok.sh index eda14ec..c9087c2 100755 --- a/ok.sh +++ b/ok.sh @@ -181,6 +181,13 @@ environment variables (for internal use): if [[ $called == $0 ]]; then # tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". ~/path/to/ok-bash/ok.sh" echo 'tip: "." (i.e. source) this file from your profile (.bashrc), e.g. ". '${_OK__PATH_TO_ME}'/ok.sh"' + echo + echo "arguments, if you need to customize (these can also be set via arguments/environment):" + echo " prompt Use the supplied prompt (e.g. prompt '> ')" + echo " prompt_default Prompt default when issueing running ok without arguments" + echo " verbose Enable verbose mode" + echo " quiet Enable quiet mode" + echo else # Reset all used environment variables unset _OK_C_HEADING; unset _OK_C_NUMBER; unset _OK_C_COMMENT; unset _OK_C_COMMAND; unset _OK_C_PROMPT From 143c290b30197584bb44778a200c7ff7d782ce3b Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Tue, 21 Aug 2018 23:05:38 +0200 Subject: [PATCH 9/9] Added auto_show installation helper --- ok.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ok.sh b/ok.sh index c9087c2..af2650f 100755 --- a/ok.sh +++ b/ok.sh @@ -185,6 +185,7 @@ if [[ $called == $0 ]]; then echo "arguments, if you need to customize (these can also be set via arguments/environment):" echo " prompt Use the supplied prompt (e.g. prompt '> ')" echo " prompt_default Prompt default when issueing running ok without arguments" + echo " auto_show Perform 'ok list-once' every time the prompt is shown (modifies \$PROMPT_COMMAND)" echo " verbose Enable verbose mode" echo " quiet Enable quiet mode" echo @@ -193,15 +194,19 @@ else unset _OK_C_HEADING; unset _OK_C_NUMBER; unset _OK_C_COMMENT; unset _OK_C_COMMAND; unset _OK_C_PROMPT unset _OK_PROMPT; unset _OK_PROMPT_DEFAULT; unset _OK_VERBOSE; unset _OK__LAST_PWD # Process some installation helpers + re_list_once=$'ok list-once' while (( $# > 0 )) ; do case $1 in prompt) if [[ $# -ge 2 ]]; then export _OK_PROMPT=$2; shift; else echo "the prompt argument needs the actual prompt as 2nd argument"; fi;; prompt_default) export _OK_PROMPT_DEFAULT=1;; verbose) export _OK_VERBOSE=2;; quiet) export _OK_VERBOSE=0;; + auto_show) if [[ ! $PROMPT_COMMAND =~ $re_list_once ]]; then export PROMPT_COMMAND="$PROMPT_COMMAND +$re_list_once"; fi;; *) echo "Ignoring unknown argument '$1'";; esac shift done + unset re_list_once fi unset called