We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 422480b commit fd495bbCopy full SHA for fd495bb
1 file changed
lib/prompt.sh
@@ -0,0 +1,35 @@
1
+# confirm "Would you really like to do a X?" && run_x || exit
2
+# use return rather than exit if bash function
3
+# NOTE: this will not work in a loop that is using read, use for loops instead with an altered IFS.
4
+sk-prompt-confirm() {
5
+ read -r -p "${1:-Are you sure? [Y/n]} " response
6
+ case $response in
7
+ [yY][eE][sS]|[yY])
8
+ true
9
+ ;;
10
+ [n])
11
+ false
12
13
+ *)
14
15
16
+ esac
17
+}
18
+
19
+sk-prompt-confirm-timeout() {
20
+ read -r -t 5 -p "${1:-Are you sure? [Y/n]} " response || return 1
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0 commit comments