m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

Updated Examples (markdown)

D630
2016-03-21 08:08:40 +00:00
parent 65045a3397
commit 01e2792969

@@ -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