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 60be64854416257459f78b32db82c2d99d67eb93
parent 545ee3f6236f7a5793e2e03bb8db7d0a7cd6381e
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue,  7 Jul 2020 08:24:37 +0200

Repeat previous command with 'r'

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

diff --git a/.local/bin/search b/.local/bin/search @@ -1,4 +1,5 @@ #!/bin/sh +histfile="$HOME/.cache/searchhist" if [ $# -lt 1 ]; then targets="$(cat "$HOME"/doc/gopherbookmarks; \ @@ -8,17 +9,21 @@ if [ $# -lt 1 ]; then cat "$HOME"/doc/bookmark.txt; dmenu_path)" - lines=10 - prompt="search:" if [ -z "$TERM" ]; then - c=$(printf '%s' "$targets" | dmenu -i -p "$prompt") || exit 1 + c=$(printf '%s' "$targets" | dmenu -i) || exit 1 else - c=$(printf '%s' "$targets" | fzy -l "$lines" -p "$prompt") || exit 1 + c=$(printf '%s' "$targets" | fzy) || exit 1 fi else c="$*" fi +if [ "$c" = "r" ]; then + c="$(tail -1 "$histfile")" +else + printf '%s' "$c" > "$histfile" +fi + regexmatch() { printf '%s' "$1" | grep -E -q "$2" }