diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-06-22 13:35:30 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-06-22 13:35:30 +0200 |
commit | 52b3327fb2e63c5756198e7f183e5f610f1f3934 (patch) | |
tree | 7932d487075754238072cec0494a9cf84934f062 | |
parent | ab76fc99422a9147f745c48e301dbbb1cd5db29d (diff) |
small refactor
-rwxr-xr-x | bin/menuscripts/mpdf | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/bin/menuscripts/mpdf b/bin/menuscripts/mpdf index d26c841..d67fdae 100755 --- a/bin/menuscripts/mpdf +++ b/bin/menuscripts/mpdf @@ -12,14 +12,11 @@ fi tmp="/tmp/dmpdf" find ${1:-$HOME/docs $HOME/dl} 2> /dev/null | grep -E ".+\.pdf" | sort > "$tmp" -choice="$(\ - sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' "$tmp" | +choice="$(sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" "$tmp" | awk '{printf "%s %s\n", NR ":", $0}' | $menucmd | - grep -oE "^[0-9]+:" | - cut -f1 -d:)" -if [ -z "$choice" ]; then - exit -fi + grep -o "^[0-9]\+:" | + cut -f 1 -d :)" +test -z "$choice" && exit 1 file="$(sed -n "${choice}p" "$tmp")" zathura "$file" & |