diff --git a/lib/frontend/ansi.py b/lib/frontend/ansi.py index 643612b..dd15ec0 100644 --- a/lib/frontend/ansi.py +++ b/lib/frontend/ansi.py @@ -129,6 +129,8 @@ def _visualize(answers, request_options, search_mode=False): and not request_options.get('add_comments') and not request_options.get('remove_text'))) + if request_options.get('no-terminal'): + result = remove_ansi(result) result = result.strip('\n') + "\n" return result, found diff --git a/share/adapters/chmod.grc b/share/adapters/chmod.grc new file mode 100644 index 0000000..7f643a6 --- /dev/null +++ b/share/adapters/chmod.grc @@ -0,0 +1,40 @@ +# with option -sI +# e.g. grc curl -sI mysite.com +# http +regexp=^(HTTP).* +colours=yellow +====== +# server +regexp=^(Server).* +colours=cyan +====== +# site +regexp=^(Link).* +colours=magenta +====== +# colouring the output of script 'cheat chmod' +# e.g. grc curl -s cheat.sh/chmod/755 +# linux string +regexp=^(Linux.*Permissions).*(String:)\s+(.*)$ +colours=yellow,green,red +====== +# linux number +regexp=^(Linux.*Permissions).*(Number:)\s+(.*)$ +colours=yellow,green,red +====== +# header +regexp=^(Special)\s+(Owner)\s+(Group)\s+(Public)$ +colours=white +====== +# setuid +regexp=^(Setuid)\s+\[.*\].*(Read).* +colours=green,bold cyan +====== +# setgid +regexp=^(Setgid)\s+\[.*\].*(Write).* +colours=green,bold yellow +====== +# sticky bit +regexp=^(Sticky bit)\s+\[.*\].*(Execute).* +colours=green,bold magenta +====== diff --git a/share/adapters/chmod.sh b/share/adapters/chmod.sh index 62bdec5..233cb4c 100755 --- a/share/adapters/chmod.sh +++ b/share/adapters/chmod.sh @@ -2,6 +2,8 @@ # Contributed by Erez Binyamin (github.com/ErezBinyamin) +GRC_STYLESHEET="${BASH_SOURCE[0]}"; GRC_STYLESHEET=${GRC_STYLESHEET%.sh}.grc + # Translate between chmod string and number # Inspired by http://permissions-calculator.org/ # Contrib to chubin - cheat.sh @@ -89,7 +91,7 @@ Setuid [$setuid]\tRead [${R[0]}]\tRead [${R[1]}]\tRead [${R[2]}] Setgid [$setgid]\tWrite [${W[0]}]\tWrite [${W[1]}]\tWrite [${W[2]}] Sticky bit [$sticky]\tExecute [${X[0]}]\tExecute [${X[1]}]\tExecute [${X[2]}] -" +" | grcat "$GRC_STYLESHEET" } chmod_calc $@