summaryrefslogtreecommitdiff
path: root/scripts/old/dmenu-filepicker-old
blob: 532fb82497a387058933f559cd88f92589c476e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

# A dmenu-based file picker (prints selected file to stdout)
# Requires: dmenu (or similar)
# Usage: dmenu-filepicker [path]

menu=${MENU:-dmenu}
menuopts="-i -l 15"

basedir="$(pwd)"

next="${@:-$(pwd)}"

while true; do
	if [ -z "$next" ]; then
		break
	elif [ "$next" = "." ]; then
		pwd
		break
	elif [ -d "$next" ]; then
		cd "$next"
		next=$(ls -a | $menu $menuopts)
	else
		echo "$next" | while read line; do
			echo "$(pwd)/$line"
		done
		break
	fi
done

cd "$basedir"

Generated with cgit - Back to sebastiano.tronto.net