iomenu

interactive text selection menu
Log | Files | Refs | README | LICENSE

commit 9c174ec5092e0424e3459de569543eb457778c05
parent 043e751461d877739b5a895d453992ea5d5f5b3c
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 22 Jun 2018 14:02:27 +0200

update the cache while a directory is selected

Diffstat:
Mbin/io-xdg-open | 30+++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/bin/io-xdg-open b/bin/io-xdg-open @@ -1,14 +1,30 @@ -#!/bin/sh -e +#!/bin/sh -ex # pick a file to open with xdg-open with iomenu with caching +# +# The cache is updated when a directory is selected. LC_COLLATE=C -mkdir -p "$HOME/.cache" +if test -f "$HOME/.cache/find" && test $# = 0 +then exec "$0" "$HOME" +elif test $# = 0 +then exec xdg-open "$(iomenu <$HOME/.cache/find)" +fi -test "$1" = -c || ! test -f "$HOME/.cache/find" && - find "$HOME" '(' -name .git -o -name CVS ')' -prune -o \ +mkdir -p "$HOME/.cache" +{ + find "$1" '(' -name .git -o -name CVS ')' -prune -o \ -type d -exec printf '%s/\n' '{}' + -o \ - -type f -exec printf '%s\n' '{}' + | - sort -o $HOME/.cache/find + -type f -exec printf '%s\n' '{}' + | tee "$HOME/.cache/$$" + grep -vF "$1" $HOME/.cache/find +} | sort -o "$HOME/.cache/find" + +s=$(iomenu <$HOME/.cache/$$) + +rm "$HOME/.cache/$$" -exec xdg-open "$(iomenu <$HOME/.cache/find)" +case $s in +('') exit 1 ;; +(*/) exec "$0" "$(cd "$s" && pwd)" ;; +(*) exec xdg-open ;; +esac