Skip to content

Commit 3f09407

Browse files
committed
added _fold
1 parent 50b0adc commit 3f09407

File tree

1 file changed

+17
-1
lines changed
  • opt/cs50/lib

1 file changed

+17
-1
lines changed

opt/cs50/lib/cli

+17-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function _ansi() {
1616
# Format backticks as bold
1717
local bold=$(printf '\033[1m')
1818
local normal=$(printf '\033[22m')
19-
echo "$input" | sed "s/\`\\([^\`]*\\)\`/${bold}\\1${normal}/g"
19+
echo "$input" | sed "s/\`\\([^\`]*\\)\`/${bold}\\1${normal}/g" | _fold
2020
}
2121

2222
function _find() {
@@ -46,6 +46,22 @@ function _find() {
4646
fi
4747
}
4848

49+
function _fold() {
50+
51+
# If command-line arguments
52+
if [[ -t 0 ]]; then
53+
input="$*"
54+
55+
# If standard input
56+
else
57+
input=$(cat)
58+
fi
59+
60+
# Wrap long lines
61+
local cols=$(tput cols)
62+
echo "$input" | fold --spaces --width=$cols
63+
}
64+
4965
function _sure() {
5066
if [[ $# -ne 1 ]]; then
5167
return 1

0 commit comments

Comments
 (0)