coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature request: fold -p STR ... Prefix each folded line with STR


From: Jazzoslav Jammovitch
Subject: Feature request: fold -p STR ... Prefix each folded line with STR
Date: Sat, 20 Apr 2013 12:50:21 +0200

Greetings, Supaninjas!

I wish to make a request for a new feature to the fold program. Often, I find
myself folding lines that comprise some kind of list such as:

== A ==
1. Hola Mundo!
2. Cows say moo when they feel chatty.
3. I scream, you scream, we all scream for icecream! -- Roberto

Folding this at 30 characters yields approximately the following list, but the
desired effect would be to add three spaces to each broken line in order to
align them with the enumeration index as demonstrated in list C.

== B ==
1. Hola Mundo!
2. Cows say moo when they
feel chatty.
3. I scream, you scream, we
all scream for icecream! --
Roberto

== C ==
1. Hola Mundo!
2. Cows say moo when they
   feel chatty.
3. I scream, you scream, we
   all scream for icecream!
   -- Roberto

Another somewhat contrived use case would be to fold the output of history at
1/3 - 1/2 of the terminal width and pipe the output into column -c 80 to make
use of the whole terminal. Like so:

$ hD -20
5900  lol                       5908  lssort
5901  history                   5909  history
5902  sBrc                      5910  vim
5903  vim                             /home/jaroslav/.bashrc
      /home/jaroslav/.bashrc    5911  history
5904  sBrc                      5912  historyPurge 15
5905  history                   5913  hD
5906  function historyPurge {   5914  hD -20
      local range=`history |    5915  hD -50
      tail                      5916  hD -40
      -n ${1:-1} |  cut -d' '   5917  hD -20
      -f                        5918  hD -30
      2`; history | tail -n 15  5919  hD -20
      ; }
5907  history

What say you? Is this a useful feature or should I forget it and improve my sed
skills instead?

-- Jaroslav



reply via email to

[Prev in Thread] Current Thread [Next in Thread]