diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2021-09-17 23:59:38 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2021-09-17 23:59:38 +0300 |
commit | a479092a592bc1f97f849410593f8a06a8688cd1 (patch) | |
tree | 6dbbe9a7d33e3d3455010f4652e2d1eaf2861997 /dotfiles/.local/bin/menuman | |
parent | 376d68b0443a60a237e9e35462781a2ff504c7ac (diff) | |
download | swayrice-a479092a592bc1f97f849410593f8a06a8688cd1.tar.gz swayrice-a479092a592bc1f97f849410593f8a06a8688cd1.zip |
Some changes/improvements
* New menuman mode to search with apropos
* Dragon drag-and-drop marked images in sxiv
* Other changes.
Diffstat (limited to 'dotfiles/.local/bin/menuman')
-rwxr-xr-x | dotfiles/.local/bin/menuman | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/dotfiles/.local/bin/menuman b/dotfiles/.local/bin/menuman index acad4c4..30a5424 100755 --- a/dotfiles/.local/bin/menuman +++ b/dotfiles/.local/bin/menuman @@ -1,19 +1,67 @@ #!/bin/sh # Search and open man page +# Options: +# -t use in terminal with fzf otherwise launch bemenu. +# -s search with apropos. -list="$(man -k . | awk '{ print $1$2 }')" +# Source settings from .bemenurc +. ~/.config/bemenurc -if [ "$1" = "-t" ]; then - chosen=$(printf "$list" | fzf) +issearch= +isterminal= + +printusage() { + echo "Options:" >2 + echo " -t use in terminal with fzf otherwise launch bemenu." >2 + echo " -s search with apropos." >2 +} + +while getopts "st" curopt "$@"; do + case "$curopt" in + "s") + issearch=1 + continue;; + "t") + isterminal=1 + continue;; + "?") + printusage + exit 1;; + esac +done + +if [ ! -z "$issearch" ]; then + if [ ! -z "$isterminal" ]; then + printf "Enter query:\t" + read query + else + query="$(echo "" | bemenu -p "Enter apropos query:" -i --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR")" + fi + if [ -z "$query" ]; then + echo "Empty query" >2 + exit 1 + fi + list="$(apropos "$query")" else - # Source settings from .bemenurc - . ~/.config/bemenurc + list="$(man -k . | awk '{ print $1$2 }')" +fi - chosen=$(printf "$list" | bemenu -p "Select man page:" -i -l 25 --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR") +if [ ! -z "$isterminal" ]; then + chosen=$(printf "$list" | fzf) +else + chosen=$(printf "$list" | bemenu -p "Select man page:" -i -l 25 --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR") fi if [ -z "$chosen" ]; then exit 0 fi +if [ ! -z "$issearch" ]; then + chosen="$(printf "$chosen" | sed "s/\(.* ([a-zA-Z0-9]*)\)\s*-.*/\1/")" +fi + +if [ ! -z "$isterminal" ]; then + man "$chosen" && exit +fi + $TERMINAL -T "man $chosen" man $chosen |