-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathymihere.sh
More file actions
executable file
·144 lines (128 loc) · 2.29 KB
/
ymihere.sh
File metadata and controls
executable file
·144 lines (128 loc) · 2.29 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
ymih() {
if [ $# = 0 ] ; then
printf '%s\n' "$YMIHERE" | sed -e "
1 {
s/^/ /
s/\$/ /
:pad
/.\{$COLUMNS\}/ ! {
s/^/>/
s/\$/</
/^>\{10\}/ s/>\{5\}/<<<<</
/<\{10\}\$/ s/<\{5\}\$/>>>>>/
b pad
}
/.\{$COLUMNS\}./ s/.//
}
2,$ {
s/^[ ]*/+ /
:indent
/^ \{$(($COLUMNS / 3))\}/ ! {
/.\{$COLUMNS\}/ ! {
s/^/ /
b indent
}
}
}"
printf '\n'
else
case "$1" in
--|-)
if [ "$#" -gt 1 ] ; then
shift
export YMIHERE="$*"
else
unset YMIHERE
while ! [ -n "$YMIHERE" ] ; do
IFS=' ' read -r YMIHERE
YMIHERE="${YMIHERE#[[:cntrl:]]}"
done
export YMIHERE
fi
;;
+)
if [ "$#" -gt 1 ] ; then
shift
export YMIHERE="$YMIHERE
$*"
else
unset INPUT
while ! [ -n "$INPUT" ] ; do
IFS=' ' read -r INPUT
done
export YMIHERE="$YMIHERE
$INPUT"
fi
;;
-h*|--help)
cat <<HELP
ymih (whY aM I Here?)
Usage:
ymih
Prints the previously set text.
ymih --
ymih -
Reads text from the terminal.
ymih [--|-] <TEXT>
Sets text from operand.
ymih + [<TEXT>]
Adds a text as an indented line to the text.
If + is used without an argument, text is read
from stdin.
ymih -h|--help
Print this help text and exit.
Author: Frank Bruder <mail@frabru.de>
HELP
;;
-*)
echo "Unsupported option: $1">&2
return 2
;;
*)
export YMIHERE="$*"
;;
esac
fi
}
yruh() {
if [ $# -gt 0 ] ; then
case "$1" in
-h*|--help)
cat <<HELP
yruh (whY aRe yoU Here?)
Asks for a text to set for ymih.
This calls
ymih --
but prints a question before and a guide text afterwards.
Usage:
yruh
Ask for why you are here and read text from stdin.
yruh -h|--help
Print this help text and exit.
Author: Frank Bruder <mail@frabru.de>
HELP
return 0
;;
-*)
printf 'Unsupported option "%s"\n' "$1">&2
return 2
;;
*)
printf 'Unsupported operand "%s"\n' "$1">&2
return 2
;;
esac
else
echo 'Why are you here?'
ymih --
fi
printf 'Okay. Type "____\010\010\010\010ymih" (wh_\010y a_\010m _\010I _\010here) if you need a reminder of\nwhy you have opened this terminal.\n' | "$(command -v ul || printf cat)"
}
case "$-" in
*i*)
if [ -t 1 ] ; then
yruh
fi
;;
esac