-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnmenu
executable file
·44 lines (41 loc) · 826 Bytes
/
nmenu
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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh -e
## Nested menu
if [ -n "$1" ]; then
cd "$1"
else
NMENU_HOME="${XDG_CONFIG_DIR:-$HOME/.config}/nmenu"
mkdir -p "$NMENU_HOME"
cd "$NMENU_HOME"
fi
show_menu() {
# shellcheck disable=SC2086
{
if [ -x menu ]; then
./menu
elif [ -f menu ]; then
cat menu
else
find . -type d
fi
} | dmenu $NMENU_MENU_ARGS
}
run_menu() {
item=$(show_menu)
if [ -f run ]; then
exec ./run "$item"
elif [ -d "$item" ]; then
cd "$item"
run_menu
elif [ -f "$item" ]; then
exec "./$item"
else
cmd="$(echo "$item" | cut -f2)"
if [ -n "$cmd" ]; then
# shellcheck disable=SC2086
exec $cmd
else
exec "$item"
fi
fi
}
run_menu