diff --git a/Examples.md b/Examples.md index 2223f1c..221040b 100644 --- a/Examples.md +++ b/Examples.md @@ -2061,6 +2061,38 @@ fman() { # Get the colors in the opened man page itself export MANPAGER="sh -c 'col -bx | bat -l man -p --paging always'" ``` +### fzf-man-pages widget (for zsh) +Same functionality as above but better +- with colored and syntax higlighting +- doesn't exit fzf when pressed enter +- `--tiebreak=begin` for improved search experience (prefers the line with matched substring closer to the beginning) +- additional keybinds for changing preview (optional) + Alt-C for [cheat sheet](https://github.com/chubin/cheat.sh) + Alt-T for [tldr](https://github.com/tldr-pages/tldr) (I've used [tealdeer](https://github.com/dbrgn/tealdeer) to customize the colors) +- `Ctrl-H` keybinding to launch the widget (works only on zsh, don't know how to do it on bash and fish (additionaly pressing`ctrl-backspace` will trigger the widget to launch too because both share the same keycode) + +![](https://user-images.githubusercontent.com/114978689/200536151-49caf164-7011-44be-943b-b9fd57a3ca78.png) + +```sh +fzf-man-widget() { + batman="man {1} | col -bx | bat -l man -p --color always --theme=\"Monokai Extended\"" + man -k . | awk -v cyan=$(tput setaf 6) -v blue=$(tput setaf 4) '{$1=cyan $1; $2= blue;} 1' | \ + fzf +i +x \ + -q "$1" \ + --ansi \ + --tiebreak=begin \ + --prompt=' Man > ' \ + --preview-window='up,85%,border-bottom' \ + --preview "${batman}" \ + --bind "enter:execute(man {1})" \ + --bind "alt-c:+change-preview(cht.sh {1})+change-prompt(ﯽ Cheat > )" \ + --bind "alt-m:+change-preview(${batman})+change-prompt( Man > )" \ + --bind "alt-t:+change-preview(tldr --color=always {1})+change-prompt(ﳁ TLDR > )" + zle reset-prompt +} +bindkey '^h' fzf-man-widget +zle -N fzf-man-widget +``` ### Python Behave BDD