dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 4b95fb275237da6bdfda93121364feb961508256
parent 9efb3d7c5f0f66f42e1255f1fd94cc5f2788440f
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Mon,  6 Jul 2020 13:27:38 +0200

Launch programs in PATH from search script

Diffstat:
M.local/bin/search | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/.local/bin/search b/.local/bin/search @@ -1,18 +1,19 @@ #!/bin/sh if [ $# -lt 1 ]; then - uris="$(cat "$HOME"/doc/gopherbookmarks; \ + targets="$(cat "$HOME"/doc/gopherbookmarks; \ grep 'href="htt' "$HOME"/doc/bookmark.html | sed 's/<\/.*>//g' | sed 's/.*<a href="//;s/">/ /;s/<\/a>//'; - cat "$HOME"/doc/bookmark.txt)" + cat "$HOME"/doc/bookmark.txt; + dmenu_path)" lines=10 prompt="search:" if [ -z "$TERM" ]; then - c=$(printf '%s' "$uris" | dmenu -i -p "$prompt") || exit 1 + c=$(printf '%s' "$targets" | dmenu -i -p "$prompt") || exit 1 else - c=$(printf '%s' "$uris" | fzy -l "$lines" -p "$prompt") || exit 1 + c=$(printf '%s' "$targets" | fzy -l "$lines" -p "$prompt") || exit 1 fi else c="$*" @@ -26,6 +27,13 @@ regeximatch() { printf '%s' "$1" | grep -i -E -q "$2" } +if command -v "$(printf '%s' "$c" | sed 's/ .*//')" >/dev/null 2>&1; then + out="$(eval "$c" 2>&1)" + if [ -n "$out" ]; then + notify "\$ $c" "$out" + fi +fi + if regeximatch "$c" '^gopher://' || \ { regexmatch "$c" '^(0|1|3|7|9|g|I|h)' && \ [ "$(printf '%s' "$c" | awk -F'\t' '{print NF}')" -eq 4 ]; }; then