diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-02-22 16:22:24 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-02-22 16:22:24 +0100 |
commit | ea363048de7ac31a9e5475a10f0cbf7c4006318d (patch) | |
tree | 54d8632fc1c1c7c91c96052d35f11f9c2efc7c58 | |
parent | a3c57ed4f09eaf13531a83c16074085ea173c539 (diff) |
changed: (dmpdf) look more like dmvid
-rwxr-xr-x | bin/dmscripts/dmpdf | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/bin/dmscripts/dmpdf b/bin/dmscripts/dmpdf index 6137e1a..cf1f0dd 100755 --- a/bin/dmscripts/dmpdf +++ b/bin/dmscripts/dmpdf @@ -1,21 +1,14 @@ #!/bin/bash -directory="${1:-$PWD}" -choice="$(\ - find "${directory}" \ - -type f \ - -iname "*.pdf" \ - -printf "%p\n" \ - | awk -F '/' '{print $(NF - 1) "/" $NF}' \ - | sort \ - | uniq \ - | dmenu -i -x -p "pdf:" -l 10 -g 2 \ - | awk -F '/' '{print $2}' \ -)" -# find matching file -file="$(\ - find "$directory" -name "*$choice*" \ +find ${1:-~/docs ~/Downloads} 2> /dev/null | grep -E ".+\.pdf" | sort > /tmp/dmpdf +choice="$(\ + sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' /tmp/dmpdf \ + | awk '{printf "%s %s\n", NR ":", $0}' \ + | dmenu -l 10 -g 1 -x -i \ + | grep -oE "^[0-9]+:" \ )" - -[[ -f "$file" ]] || exit 1 +if [ -z "$choice" ]; then + exit +fi +file="$(sed -n "${choice::-1}p" /tmp/dmpdf)" evince "$file" & |