aboutsummaryrefslogtreecommitdiff
path: root/dmenu-filepicker
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu-filepicker')
-rwxr-xr-xdmenu-filepicker16
1 files changed, 12 insertions, 4 deletions
diff --git a/dmenu-filepicker b/dmenu-filepicker
index 7a3da9f..e2642b2 100755
--- a/dmenu-filepicker
+++ b/dmenu-filepicker
@@ -2,10 +2,18 @@
2 2
3# A dmenu-based file picker (prints selected file to stdout) 3# A dmenu-based file picker (prints selected file to stdout)
4# Requires: dmenu (or similar) 4# Requires: dmenu (or similar)
5# Usage: dmenu-filepicker [path] 5# Usage: dmenu-filepicker [-m menu] [path]
6 6
7menu=dmenu 7menu="dmenu -i -l 15"
8menuopts="-i -l 15" 8
9while getopts "m:" opt; do
10 case "$opt" in
11 m)
12 menu="$OPTARG"
13 ;;
14 esac
15done
16shift `expr $OPTIND - 1`
9 17
10fullpath=$(realpath ${@:-"$(pwd)"}) 18fullpath=$(realpath ${@:-"$(pwd)"})
11 19
@@ -15,7 +23,7 @@ while true; do
15 break 23 break
16 elif [ -d "$fullpath" ] || [ -z "$fullpath" ]; then 24 elif [ -d "$fullpath" ] || [ -z "$fullpath" ]; then
17 if [ -z "$fullpath" ]; then fp="/"; else fp="$fullpath"; fi 25 if [ -z "$fullpath" ]; then fp="/"; else fp="$fullpath"; fi
18 sel=$(ls -a "$fp" | sed 's|.*/||' | $menu $menuopts) 26 sel=$(ls -a "$fp" | sed 's|.*/||' | $menu)
19 if [ "$sel" = ".." ]; then 27 if [ "$sel" = ".." ]; then
20 fullpath=$(echo "$fullpath" | sed "s|/[^/]*$||") 28 fullpath=$(echo "$fullpath" | sed "s|/[^/]*$||")
21 else 29 else

Generated with cgit - Back to sebastiano.tronto.net