Quantcast

[nearly offtopic] Feature that makes easy to locate to similar previous commands

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[nearly offtopic] Feature that makes easy to locate to similar previous commands

Pedro-2
Hi,

Octave have a feature that when you put some commands, for example:

version
pkg list
ls

And if now you press "v" and later, the "up" arrow, you go to the
first occurrence that start with "v", so this is "version" (more up
arrow goes to more terms that start with "v").
This is great.
My question is if I can make this with simple bash commandline,
editing something in .bashrc ?

Thanks!
Pedro
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [nearly offtopic] Feature that makes easy to locate to similar previous commands

Stephen Montgomery-Smith
On 03/07/2013 07:42 PM, Pedro wrote:

> Hi,
>
> Octave have a feature that when you put some commands, for example:
>
> version
> pkg list
> ls
>
> And if now you press "v" and later, the "up" arrow, you go to the
> first occurrence that start with "v", so this is "version" (more up
> arrow goes to more terms that start with "v").
> This is great.
> My question is if I can make this with simple bash commandline,
> editing something in .bashrc ?

http://stackoverflow.com/questions/1030182/how-do-i-change-bash-history-completion-to-complete-whats-already-on-the-line

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [nearly offtopic] Feature that makes easy to locate to similar previous commands

Jordi Gutiérrez Hermoso-2
In reply to this post by Pedro-2
On 7 March 2013 20:42, Pedro <[hidden email]> wrote:

> Hi,
>
> Octave have a feature that when you put some commands, for example:
>
> version
> pkg list
> ls
>
> And if now you press "v" and later, the "up" arrow, you go to the
> first occurrence that start with "v", so this is "version" (more up
> arrow goes to more terms that start with "v").
> This is great.
>
> My question is if I can make this with simple bash commandline,
> editing something in .bashrc ?

Both Octave and bash are using GNU readline, a common library for
command line editing. Octave binds <up> to readline's
history-search-backwards command by default:

    http://hg.savannah.gnu.org/hgweb/octave/file/caf4f386aaab/scripts/startup/inputrc

Just copy this file into your ~/.inputrc so that bash's readline also reads it.

- Jordi G. H.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [nearly offtopic] Feature that makes easy to locate to similar previous commands

Pedro-2
On Fri, Mar 8, 2013 at 2:49 AM, Stephen Montgomery-Smith
<[hidden email]> wrote:
> http://stackoverflow.com/questions/1030182/how-do-i-change-bash-history-completion-to-complete-whats-already-on-the-line

On Fri, Mar 8, 2013 at 3:09 AM, Jordi Gutiérrez Hermoso
<[hidden email]> wrote:

> On 7 March 2013 20:42, Pedro <[hidden email]> wrote:
>> Hi,
>>
>> Octave have a feature that when you put some commands, for example:
>>
>> version
>> pkg list
>> ls
>>
>> And if now you press "v" and later, the "up" arrow, you go to the
>> first occurrence that start with "v", so this is "version" (more up
>> arrow goes to more terms that start with "v").
>> This is great.
>>
>> My question is if I can make this with simple bash commandline,
>> editing something in .bashrc ?
>
> Both Octave and bash are using GNU readline, a common library for
> command line editing. Octave binds <up> to readline's
> history-search-backwards command by default:
>
>     http://hg.savannah.gnu.org/hgweb/octave/file/caf4f386aaab/scripts/startup/inputrc
>
> Just copy this file into your ~/.inputrc so that bash's readline also reads it.

@Jordi & @Stephen thanks for your help, that's what I was looking for.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [nearly offtopic] Feature that makes easy to locate to similar previous commands

Pedro-2
On Fri, Mar 8, 2013 at 3:20 AM, Pedro <[hidden email]> wrote:

> On Fri, Mar 8, 2013 at 2:49 AM, Stephen Montgomery-Smith
> <[hidden email]> wrote:
>> http://stackoverflow.com/questions/1030182/how-do-i-change-bash-history-completion-to-complete-whats-already-on-the-line
>
> On Fri, Mar 8, 2013 at 3:09 AM, Jordi Gutiérrez Hermoso
> <[hidden email]> wrote:
>> On 7 March 2013 20:42, Pedro <[hidden email]> wrote:
>>> Hi,
>>>
>>> Octave have a feature that when you put some commands, for example:
>>>
>>> version
>>> pkg list
>>> ls
>>>
>>> And if now you press "v" and later, the "up" arrow, you go to the
>>> first occurrence that start with "v", so this is "version" (more up
>>> arrow goes to more terms that start with "v").
>>> This is great.
>>>
>>> My question is if I can make this with simple bash commandline,
>>> editing something in .bashrc ?
>>
>> Both Octave and bash are using GNU readline, a common library for
>> command line editing. Octave binds <up> to readline's
>> history-search-backwards command by default:
>>
>>     http://hg.savannah.gnu.org/hgweb/octave/file/caf4f386aaab/scripts/startup/inputrc
>>
>> Just copy this file into your ~/.inputrc so that bash's readline also reads it.
>
> @Jordi & @Stephen thanks for your help, that's what I was looking for.

There is a caution:

when you make your own ~/.inputrc you are overriding the default .inputrc
for example, after creating ~/.inputrc you can not make:
"\eOd": backward-word
"\eOc": forward-word
with arrows

it will get:
$ ;5C;5D

and where is inputrc default system file ?
in
/etc/inputrc

so you will need to make something like:

cp /etc/inputrc ~/.inputrc

and then copy that history-search-backward and forward
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Loading...