text: get modification time after replacing file content in place
[vis.git] / vis-open
blob0bcdd5c5b793085649880b8fba8cae641dcd1ef7
1 #!/bin/sh
3 PATTERN="."
4 [ -z "$VIS_MENU" ] && VIS_MENU="slmenu"
5 [ -z "$VIS_MENU_ARGS" ] && VIS_MENU_ARGS="-b"
7 while [ $# -gt 0 ]; do
8 case "$1" in
9 -h|--help)
10 echo "usage: $0 [-h] [-p prompt] [file-pattern]"
11 exit 0;
13 -p)
14 VIS_MENU_ARGS="$VIS_MENU_ARGS -p $2"
15 shift
16 shift
19 PATTERN=$*
20 break
22 esac
23 done
25 if ! type "$VIS_MENU" >/dev/null 2>&1; then
26 if [ ! -z "$DISPLAY" ] && type "dmenu" >/dev/null 2>&1; then
27 VIS_MENU="dmenu"
28 else
29 echo "Neither slmenu nor dmenu found"
30 exit 1
34 DIR=""
36 while true; do
37 SEL=$({ echo ..; ls -1 $PATTERN; } | $VIS_MENU $VIS_MENU_ARGS)
38 [ -z "$SEL" ] && exit 1
39 [ ! -z "$DIR" ] && SEL="$DIR/$SEL"
40 if [ -d "$SEL" ]; then
41 DIR="$SEL"
42 PATTERN="$DIR"
43 else
44 echo "$SEL"
45 exit 0
47 done