Skip to content

Commit 55abf40

Browse files
committed
dot_add.sh: Add -d option for dialog menu
1 parent 4021985 commit 55abf40

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

lib/dot_add.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dot_add() {
88
do
99
case $OPT in
1010
"m" ) message="${OPTARG}";;
11+
"d" ) use_dialog="${OPTARG}";;
1112
esac
1213
done
1314

@@ -119,7 +120,7 @@ dot_add() {
119120
fi
120121

121122
# if the second arugument isn't provided, provide suggestion
122-
if [ $# = 1 ];then
123+
if [ $# = 1 ]; then
123124
suggest "$1" && return 0 || return 1
124125
fi
125126

@@ -131,7 +132,20 @@ dot_add() {
131132
return 1
132133
} #}}}
133134

134-
dot_add_main "$@"
135+
136+
137+
if ${use_dialog} -a [ $# = 0 ]; then
138+
local tmpfifo _from _to
139+
tempfifo="/tmp/dot_dialog.fifo"
140+
mkfifo "$tempfifo"
141+
142+
dialog \
143+
--fselect "$(pwd)/" $(get_height 18) $(get_width 80) \
144+
2> "$tempfifo" &
145+
_from="$(cat ${tempfifo})"
146+
else
147+
dot_add_main "$@"
148+
fi
135149

136150
unset -f orig_to_dot add_to_dotlink if_islink suggest check_dir
137151
unset -f $0

0 commit comments

Comments
 (0)