From 01e2792969592532b7649967557a27d43f7e51b4 Mon Sep 17 00:00:00 2001 From: D630 Date: Mon, 21 Mar 2016 08:08:40 +0000 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 76 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/Examples.md b/Examples.md index 72320e1..e9f90a5 100644 --- a/Examples.md +++ b/Examples.md @@ -237,35 +237,55 @@ builtin bind '"\C-r": "\C-x1\e^\er"' ```sh # Toggle bash options (set and shopt) -BOLD=$(tput bold || tput md) -RESET=$(tput sgr0 || tput me) -GREEN=$(tput setaf 2 || tput AF 2) -RED=$(tput setaf 1 || tput AF 1) -#WHITE=$(tput setaf 7 || tput AF 7) - -while read -r b o n _ +__do () +while + builtin read -r b o n _ do - case "${b}${o}" in - "set+o") set -o "$n" ;; - "set-o") set +o "$n" ;; - "shopt-s") shopt -u "$n" ;; - "shopt-u") shopt -s "$n" ;; - esac - printf ${RESET} -done < <( - < <(shopt -p ; shopt -op) sed " - / -[so] / { - s/$/ ${BOLD}${GREEN}enabled/; - b return - }; { - s/$/ ${BOLD}${RED}disabled/; - }; - : return; - " | - sort -k 3 | - column -t | - fzf --ansi --multi --with-nth=3.. --tiebreak=begin -) + case ${b}${o} in + set+o) + builtin set -o "$n" + ;; + set-o) + builtin set +o "$n" + ;; + shopt-s) + builtin shopt -u "$n" + ;; + shopt-u) + builtin shopt -s "$n" + esac +done + +__select () +{ + builtin typeset \ + BOLD=$(command tput bold || command tput md;) \ + RESET=$(command tput sgr0 || command tput me;) \ + GREEN=$(command tput setaf 2 || command tput AF 2;) \ + RED=$(command tput setaf 1 || command tput AF 1;); + + command sed " + / -[so] / { + s/$/ ${BOLD}${GREEN}enabled${RESET}/; + b return + }; { + s/$/ ${BOLD}${RED}disabled${RESET}/; + }; + : return; + " \ + | command sort -k 3 \ + | command column -t \ + | command fzf --ansi --multi --with-nth=3.. --tiebreak=begin; +} + +__input () +{ + builtin shopt -p + builtin shopt -op +} + + +__do < <(__select < <(__input)) ``` ### Processes