bug-bash
[Top][All Lists]
Advanced

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

Re: bind -x and multiple prompt/command lines


From: Jesper Nygårds
Subject: Re: bind -x and multiple prompt/command lines
Date: Mon, 5 May 2014 08:11:56 +0200

Chet,

Not that it is pressing in any way, but have you had any time to look at
this?


On Tue, Apr 22, 2014 at 1:34 PM, Jesper Nygårds <address@hidden>wrote:

> Here are simplified versions of two functions that I have written. Both
> are inspired by similar functions floating around on the zsh mailing lists.
> The first copies the previous word on the command line, and the second one
> converts three consecutive dots (...) into ../.., and you can then keep
> adding levels by typing . repeatedly.
>
> Note that I am by no means an expert in Bash programming, so I'm sure the
> same thing could be done more elegantly.
>
>
> bind -x '".":_rationalise-dot'
> bind -x '"\e:":_copy-previous-word'
>
> _copy-previous-word () {
>     local -a words
>     eval words=($READLINE_LINE)
>     #NOTE: copies quoted words correctly, but does not insert with the
> escape intact
>     address@hidden
>     READLINE_POINT=${#READLINE_LINE}
> }
>
> _rationalise-dot () {
>     if [[ ${READLINE_LINE:0:$READLINE_POINT} == *\.\. ]]; then
>
> READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}/..${READLINE_LINE:$READLINE_POINT}"
>         ((READLINE_POINT+=3))
>     else
>
> READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}.${READLINE_LINE:$READLINE_POINT}"
>         ((READLINE_POINT++))
>     fi
> }
>
>
>
> On Fri, Apr 18, 2014 at 3:13 PM, Chet Ramey <address@hidden> wrote:
>
>> On 4/15/14, 11:22 AM, Jesper Nygårds wrote:
>> > I don't have any solution to offer, but I would like to second the wish
>> for
>> > this to work better, and for the same reason: I have written several
>> very
>> > useful functions for rewriting the command line, binding them with bind
>> -x.
>> > Like Rob, I have concluded that it does not work well with a multi-line
>> > prompt, as the visual effect of the prompt moving further and further
>> down
>> > is rather unpleasant.
>>
>> Can you send me one or two so I can play around with them and see what the
>> options are?
>>
>> Chet
>>
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                  ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, ITS, CWRU    address@hidden
>> http://cnswww.cns.cwru.edu/~chet/
>>
>
>


reply via email to

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