scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

commit 3f190a17b90cb3c641ca0ead72eb86ec3dd36651
parent dde2e2618499ddf4c7644418f792113fbe19b955
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sat, 12 Feb 2022 16:26:04 +0100

Simplified dmenu-filepicker (but did not solve the change-of-focus problem I was trying to fix)

Diffstat:
Mdmenu-filepicker | 26++++++++++----------------
Cdmenu-filepicker -> old/dmenu-filepicker-old | 0
2 files changed, 10 insertions(+), 16 deletions(-)

diff --git 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 diff --git a/dmenu-filepicker b/old/dmenu-filepicker-old