From 3f190a17b90cb3c641ca0ead72eb86ec3dd36651 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 12 Feb 2022 16:26:04 +0100 Subject: Simplified dmenu-filepicker (but did not solve the change-of-focus problem I was trying to fix) --- dmenu-filepicker | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'dmenu-filepicker') diff --git a/dmenu-filepicker b/dmenu-filepicker index 532fb82..7538008 100755 --- a/dmenu-filepicker +++ b/dmenu-filepicker @@ -4,28 +4,22 @@ # Requires: dmenu (or similar) # Usage: dmenu-filepicker [path] -menu=${MENU:-dmenu} +menu=dmenu menuopts="-i -l 15" -basedir="$(pwd)" - -next="${@:-$(pwd)}" +fullpath=$(realpath ${@:-$(pwd)}) while true; do - if [ -z "$next" ]; then - break - elif [ "$next" = "." ]; then - pwd + if [ "$sel" = "." ]; then + echo "$fullpath" | sed 's|/\.||' break - elif [ -d "$next" ]; then - cd "$next" - next=$(ls -a | $menu $menuopts) + elif [ -d "$fullpath" ]; then + sel=$(ls -a "$fullpath" | sed 's|.*/||' | $menu $menuopts) + fullpath=$(printf "$fullpath/%s\n" $sel) else - echo "$next" | while read line; do - echo "$(pwd)/$line" - done + echo "$fullpath" break fi -done -cd "$basedir" + [ -z "$sel" ] && break +done -- cgit v1.3