mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 03:20:26 +10:00
Pushing dmenu and related scripts.
This commit is contained in:
29
.dmenu/dbrowse
Executable file
29
.dmenu/dbrowse
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# TODO: multisel
|
||||
|
||||
target="$1"
|
||||
[ -z "$target" ] && target="$(realpath .)"
|
||||
prompt="$2"
|
||||
|
||||
while true; do
|
||||
p="$prompt"
|
||||
[ -z "$p" ] && p="$target"
|
||||
sel="$(ls -1a "$target" |grep -v '^\.$' | dmenu -p "$p" -l 25)"
|
||||
ec=$?
|
||||
[ "$ec" -ne 0 ] && exit $ec
|
||||
|
||||
c="$(echo "$sel" |cut -b1)"
|
||||
if [ "$c" = "/" ]; then
|
||||
newt="$sel"
|
||||
else
|
||||
newt="$(realpath "${target}/${sel}")"
|
||||
fi
|
||||
|
||||
if [ -e "$newt" ]; then
|
||||
target="$newt"
|
||||
if [ ! -d "$target" ]; then
|
||||
echo "$target"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user