[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: fold -p STR ... Prefix each folded line with STR
From: |
Pádraig Brady |
Subject: |
Re: Feature request: fold -p STR ... Prefix each folded line with STR |
Date: |
Sat, 20 Apr 2013 18:02:17 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
unarchive 6195
stop
On 04/20/2013 11:50 AM, Jazzoslav Jammovitch wrote:
> 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?
Yes, this does have merit, but as responded to the
very similar request in http://bugs.gnu.org/6195,
fmt and sed might suffice. If not then we can reconsider.
thanks!
Pádraig.