Skip to content

Commit

Permalink
added _fold
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Aug 14, 2024
1 parent 50b0adc commit 3f09407
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion opt/cs50/lib/cli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function _ansi() {
# Format backticks as bold
local bold=$(printf '\033[1m')
local normal=$(printf '\033[22m')
echo "$input" | sed "s/\`\\([^\`]*\\)\`/${bold}\\1${normal}/g"
echo "$input" | sed "s/\`\\([^\`]*\\)\`/${bold}\\1${normal}/g" | _fold
}

function _find() {
Expand Down Expand Up @@ -46,6 +46,22 @@ function _find() {
fi
}

function _fold() {

# If command-line arguments
if [[ -t 0 ]]; then
input="$*"

# If standard input
else
input=$(cat)
fi

# Wrap long lines
local cols=$(tput cols)
echo "$input" | fold --spaces --width=$cols
}

function _sure() {
if [[ $# -ne 1 ]]; then
return 1
Expand Down

0 comments on commit 3f09407

Please sign in to comment.