diff --git a/opt/cs50/lib/cli b/opt/cs50/lib/cli index f757b99..dcba5e3 100644 --- a/opt/cs50/lib/cli +++ b/opt/cs50/lib/cli @@ -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() { @@ -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