dmenu-filepicker-old (488B)
1 #!/bin/sh 2 3 # A dmenu-based file picker (prints selected file to stdout) 4 # Requires: dmenu (or similar) 5 # Usage: dmenu-filepicker [path] 6 7 menu=${MENU:-dmenu} 8 menuopts="-i -l 15" 9 10 basedir="$(pwd)" 11 12 next="${@:-$(pwd)}" 13 14 while true; do 15 if [ -z "$next" ]; then 16 break 17 elif [ "$next" = "." ]; then 18 pwd 19 break 20 elif [ -d "$next" ]; then 21 cd "$next" 22 next=$(ls -a | $menu $menuopts) 23 else 24 echo "$next" | while read line; do 25 echo "$(pwd)/$line" 26 done 27 break 28 fi 29 done 30 31 cd "$basedir"