10.6 bash history-search-backwards

This is a repost from http://discussions.apple.com/message.jspa?messageID=10954384
10.6 broke my terminal history search
In 10.4 I added
bind '"M-[A": history-search-backward'
bind '"M-[B": history-search-forward'
to my .bash_profile allowing me to use the up/down arrows to search through the history in terminal, but as of 10.6 this no longer works.
I would like the up and down arrows to perform a search of the history for the string I have typed in the terminal. That is if I had issued the following sequence of commands in the terminal,
$cd ~/
$nano .bash_profile
$vi .bash_profile
so now these commands are sequentially listed in my bash history. Now if I press the up arrow, the first command to come up will be the last one that I entered, that is, $vi .bash_profile. Now if I had instead pressed up three times, the command, $cd ~/ would come up. Now what I want bash to do, and had working in OS X 10.4, is if I type a string into the terminal (and DO NOT press ENTER) such as, $cd , then I press up, bash will search through the terminal history for the instances of the command cd that I have previously entered. This is the same behavior as the MATLAB command prompt.
I know this is possible because it used to work. I would like to have this behavior again because it is very useful. I do know that I can use crl-R to search the history, but this is kind of a pain to use and it doesn't work very well.
I added the above code to ~/.inputrc and now if I type the letter 'b' in terminal I get the output
{quote}
"": history-search-forward
{quote}
It only does this for the the letter 'b'. I have tried all the other keys and there is no weird output. What is up with bash?
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Also see threads:
http://forums.macosxhints.com/showthread.php?p=569961#post569961 Mac OS X Hints 10.6 bash history-search-backwards
http://www.macosxhints.com/article.php?story=20031026174236860 Mac OS X Hints 10.3: Assign arrow keys to history search in bash

I have the following in my .bashrc file:
# Setup Command line editing using vi mode (default is Emacs).
# Map Ctrl-P and Up-arrow as command recall (previous),
# with Ctrl-N and Down-arrow as next (foreword) command.
# Viewing key binding:
# bind -p | more # key bindings
# bind -s | more # macros (like below)
# bind -m vi-command -p | more # key bindings
# bind -m vi-command -s | more # macros (like below)
shopt -s -o vi # set vi command line editing.
bind '"C-p": "ekA"' # Ctrl-P: when in insert mode
bind -m vi-command '"C-p": "kA"' # Ctrl-P: when in insert mode
bind '"C-n": "ejA"' # Ctrl-N: when in command mode
bind -m vi-command '"C-n": "jA"' # Ctrl-N: when in command mode
# I have had problems with a Linux version of Bash 2.05.8(1) that did not
# like it when I remapped the up and down arrow keys, so if I find myself
# with that version of bash, I do not try to remap them.
# "cat -v" can be very useful for determing what the escape sequence being
# issued by an keypad or function key. Keep in minde that the keypad has
# multiple modes the terminal emulator can be placed in, which alters the
# escape sequence, hence the multiple sets of mapping for up and down arrow
# in both vi-insert and vi-command mode.
if [[ "$BASH_VERSION" != 2.05.8(1) || $OSTYPE = darwin ]]; then #{
bind '"M-OA": "ekA"' # Up-arrow: when in insert mode
bind -m vi-command '"M-OA": "kA"' # Up-arrow: when in insert mode
bind '"M-OB": "ejA"' # Down-arrow: when in command mode
bind -m vi-command '"M-OB": "jA"' # Down-arrow: when in command mode
bind '"M-[A": "ekA"' # Up-arrow: when in insert mode
bind -m vi-command '"M-[A": "kA"' # Up-arrow: when in insert mode
bind '"M-[B": "ejA"' # Down-arrow: when in command mode
bind -m vi-command '"M-[B": "jA"' # Down-arrow: when in command mode
fi #}
The above does work for me on ALL my platforms (Mac OS X, Tiger, Leopard, Snow Leopard), Linux, Solaris, AIX, and Windows-Cygwin.
I use vi command line editing, so if you prefer the emacs command line editing, then the above will not work for you, in some cases I map the up/down arrows and Control-P/Control-N to vi commands.

Similar Messages

  • Linux-ck and bash's history-search-backward

    This issue seems really weird to me. I have this in my .inputrc:
    $if mode=vi
    set keymap vi-command
    # these are for vi-command mode
    "\ek": history-search-backward
    "\ej": history-search-forward
    "\e.": yank-last-arg
    set keymap vi-insert
    # these are for vi-insert mode
    "\ek": history-search-backward
    "\ej": history-search-forward
    "\e.": yank-last-arg
    $endif
    This has been working for ages and still works when I boot the standard 3.0 kernel. But when I boot the 3.0-ck kernel, alt+j and alt+k do become previous-history and next-history respectively.
    So, what does the ck-kernel has to do with these bash bindings?

    I would like the up and down arrows to perform a search of the history for the string I have typed in the terminal. That is if I had issued the following sequence of commands in the terminal,
    +$cd ~/+
    +$nano .bash_profile+
    +$vi .bash_profile+
    so now these commands are sequentially listed in my bash history. Now if I press the up arrow, the first command to come up will be the last one that I entered, that is, +$vi .bash_profile+. Now if I had instead pressed +up+ three times, the command, +$cd ~/+ would come up. Now what I want bash to do, and had working in OS X 10.4, is if I type a string into the terminal (and DO NOT press ENTER) such as, +$cd+ , then I press +up+, bash will search through the terminal history for the instances of the command +cd+ that I have previously entered. This is the same behavior as the MATLAB command prompt.
    I know this is possible because it used to work. I would like to have this behavior again because it is very useful. I do know that I can use +crl-R+ to search the history, but this is kind of a pain to use and it doesn't work very well.
    Message was edited by: jetak

  • Terminal history-search-backwards

    Terminal's history-search-backwards appears broken in Leopard.
    The following in .bash_profile in Tiger allowed a quick search in Terminal's history (i.e. 'ls' and up arrow listed all ls commands in the history)
    bind '"\M-[A": history-search-backward'
    bind '"\M-[B": history-search-forward'
    In Leopard, it no longer works for me. Can anyone confirm?
    Tony

    changing \M- to \e fixed it:
    bind '"\e[A": history-search-backward'
    bind '"\e[B": history-search-forward'

  • Bash history

    my bash cmdhist, invoked by the <prior> key only remembers one command. I emptied ~/.bash_history and it remembers the first command entered in the new ~/.bash_history but not the rest.
    shopt
    autocd off
    cdable_vars off
    cdspell off
    checkhash off
    checkjobs off
    checkwinsize off
    cmdhist on
    compat31 off
    compat32 off
    compat40 off
    compat41 off
    dirspell off
    dotglob off
    execfail off
    expand_aliases on
    extdebug off
    extglob off
    extquote on
    failglob off
    force_fignore on
    globstar off
    gnu_errfmt off
    histappend off
    histreedit off
    histverify off
    hostcomplete on
    huponexit off
    interactive_comments on
    lastpipe off
    lithist off
    login_shell off
    mailwarn off
    no_empty_cmd_completion off
    nocaseglob off
    nocasematch off
    nullglob off
    progcomp on
    promptvars on
    restricted_shell off
    shift_verbose off
    sourcepath on
    xpg_echo off

    Aha!  <Prior> is the <PageUp> key!  <Prior> is working on the OP's keyboard exactly the way it does on mine – it takes me to the beginning of the history file, the first command.  To access the last command in the history, use the <Up> (arrow).  More presses of the <Up> key take you further into bash history.
    Somewhat off topic, but not too far off:
    Actually, I would use '!!' to repeat the very last command and '!-2' for the command before that, and so on.  When I do not want the command to execute, I'll use this format: '!-5:p'.  That will print the fifth command back in history but won't execute it.
    You can use a pipe and grep the history command output when searching through it:
    history | grep wget
    When I find the command's event designator, I'll use it, '!507'.
    I add comments on the command line when I know I'll want a complex or a long command again soon:
    $ mupdf -r 96 ~/shared/books/poetry/pdf/leaves_of_grass.pdf 102 & # Add 26 to page no.
    That lets me search more quickly using 'Ctrl-R' and then '#' (or '##', or '###'...).
    Last edited by thisoldman (2011-12-11 23:29:44)

  • How to enhance Interaction History Search in CRM 2007?

    Hi experts,
    Is there any BADI available to enhance the existing Interaction History Search in IC Agent Profile?
    Thanks and Regards,
    Rohit

    Dear Rohit,
    Using the below steps you can quickly find out the BADIs related to any transaction.
    1) Put a breakpoint in the FM SXV_GET_CLIF_BY_NAME
    2) Run your transaction(e.g. Interaction History Search). It will stop at the breakpoint you have in the above FM.
    3) Chekc the value of the Fm parameter name. This will contain the BADI names.
    Alternatively you can get the BADI names the following way
    1)Go to the method GET_INSTANCE of the class CL_EXITHANDLER and put a break point there.
    2) Run your transaction(e.g. Interaction History Search). It will stop at the breakpoint you have in the above method.
    3) Chekc the value of the filed  exit_name. This will contain the BADI names.
    Hope this helps.
    Regards
    Anupam
    Edited by: Anupam Koley on Aug 11, 2008 11:55 AM
    Edited by: Anupam Koley on Aug 11, 2008 11:57 AM

  • Add custom fields to Interaction History Search.

    Hi,
    My requirement is to add two new attributes to the interaction history search screen.
    1) Process Type
    2) Creatyed By
    I have added these two fields to the Search Query Structure through Append Structure.
    Now problem is to do the backend logic.Means two restrict the records based on these values.
    Are there any BADI's available for this?
    Please advice.
    Version : CRM 2007.
    Thanks,
    Adi.

    Hi,
    Go through the following blog may be useful to you
    /people/stephen.johannes/blog/2008/01/25/crm-40-to-52-customerh-fields
    Regards,
    Deepak

  • Searching backwards in calendar

    It really amazes me that no one in the Apple iPAD/iPhone world seems to find wanting to search "backwards" in their calendar unimportant.
    Not many people seem to know that you cannot search for anything in the Calendar a year prior to the current date.
    I do this at least once a day on my PALM Calendar and it is such a useful tool for recalling events.

    This has been commented on before from time to time. Since it doesn't come up very often, maybe we can infer that it's important only to a relatively small proportion of users. But I can well understand that, to that group, it is very important. To me, it's an irritation, but I take it as one of the compromises inherent in mobile computing. What with 64GB iPads etc, many of those compromises should now be things of the past (256K Palm Pilot anyone?).
    If you haven't already done so, you can leave feedback at
    http://www.apple.com/feedback/ipad.html
    Apple doesn't reply directly to feedback posts, but does read and take note of them
    Message was edited by: nick101

  • Interaction history search - Business activity - default

    Dear Experts,
          In Intearction history search we need to show the Business activities to be defaulted when the screen is launched. How could we acheive this?
    Thanks & REgards,
    Kanthimath

    Hi Kanthimath,
    Did you manage to find an answer? I have an similar requirement in my project.
    Thanks,
    Angel

  • [solved] bash history disappears frequently

    I have got a very annoying problem: My bash history "resets" from time to time for no perceivable reason. I hate to lose anything less than the last, say, 500 commands and yet the ******** thing sometimes get an amnesia attack.
    Any ideas what might cause this?
    Last edited by macaco (2015-05-06 15:35:25)

    https://bbs.archlinux.org/viewtopic.php?id=150992
    If that doesn't help, post your .bashrc and other shell profile configuration files.

  • Save Bash History Merged?

    I'd REALLY like to save BASH history from multiple windows and sessions.
    How would I access the various histories of multiple windows and save them before exiting automatically?
    Is there a "trap" command or something that I could script to execute upon exiting the session?  Perhaps to
    merge these into a single HISTFILE?
    ALSO - is there a way to dynamically update the window title header?  Such as copying the current prompt into the title
    and to give details on the job, the remote machine being accessed, etc.?

    I assumed that the OP knew that his problem (passwords) were in root's history.
    Unless you have a habit of running sudo with -H or if you have root logins enabled, root shares your settings (since sudo without -H keeps the original user's HOME) and runs .bashrc from the original user's HOME, saves history in there etc.
    Quick test with:
    host user $ sudo bash
    Password:
    host user # echo hello_world
    hello_world
    host user # exit
    host user $ grep hello_world .bash_history
    echo hello_world
    host user $

  • Ticket History Search - CRM

    Hi,
    I have a customized CRM ticket history search which consists of 15 fields using webdynpro. Ticket history search is used to search the tickets which are created using crmd_order.
    Ticket history search module consists of both customized (like company name, Main-category and Sub-category and standard fields). I am facing the problem to give search functionality for all the 15 combinations which is 15! (factorial).
    I have used standard function module in the class CRM_SERVICE_PROCESSES_SEARCH. This function module dosnt include customized fields. So there is no link between customized and standard function module.
    Can anybody suggest me how to give search functionality for all possible fields.
    Thanks.

    hi,
    if you go in SE37 you can see that the function module CRM_SERVICE_PROCESSES_SEARCH is foreseen for extension. this is using the below one
    this function CRM_SERVICE_PORTAL_SEARCH might be better to use this one
    for the display
    the field REQUESTED_COLUMNS allows you to extend the display to other fields but not the search criteria
    You can add your own field there this is working fine , I have tested with my own developed fields (run SE37 in test mode and add your fields there)
    For the selection
    this is object oriented coding and I guess implementing your own method is the solution.
    best regards
    Xavier

  • Is there a way to audit Safari Browser history, searches, activity?

    I am not new to technology on the PC/Windows side of things.  However, I am fairly new to Apple products and I am finding them very easy to set up and use which - nice work Apple!  But I am finding that the level granularity and management in the OS is missing.  I have two children who use our family-owned iPads for both school and personal.  Other than installing a 3rd party browser (which was tried several times and met with an awful experience for both the user and the parent) or locking down the age-rating (which simply blocked a lot of relevant sites) - I could find no way to simply monitor my children's activities using Safari.
    I do not want to lock down anything, I simply want to see what they're searching for and viewing and doing on Safari so I can ascertain whether to strike up a well-time conversation around whatever subject I felt necessary.  I realize i can check the history but that is easily cleared.
    Is what i'm looking for possible?  I know with Microsoft Family Safety you can do this insanely easily for Internet Explorer and it gets very granular.  Is this possible with Apple Safari? 
    If this is not possible, I would say this is a gigantic miss for Apple.  With kids being asked to use iPads for their schoolwork and using it at home all the time, where are the family safety controls that parents can put in place to monitor activity (not lock it down)?
    thanks for any guidance in advance.

    For Safari history tap the bookmark icon( open book to the right of the search field). When it opens tap history.

  • Delete my history search

    How do I clear the history on my Google search and Safari search?

    Thank you, what you suggested did the job. It was so easy, now I know how to do it ,in case I need to do it again.

  • Interaction history search problems

    Hi Gurus,
    Good day,
    I am having problem when i save a service ticket its getting saved 3 times 2 times as business activity with blank description and one time as customised transaction, and when i search in interaction history its not showing anything but the record exsists in the table.
    Regds
    Jitender

    Please check below thread if it helps:
    http://scn.sap.com/thread/3351726
    Thanks
    Kumar

  • History Search by URL (rather than by keywords)

    +** sorry if this had been covered before. If so, please kindly direct me to the discussions. I was unable to find it in any discussion. **+
    Is it possible to search the Safari history list by URL? For instances, I want to search (and delete) anything relating to mail.yahoo.com or facebook.com.
    If we use the keyword search, it'll bring up any pages that contain mail.yahoo.com (or even just partial of those words). This search result is rather meaningless, for the task anyway.
    Sorry if this had been asked, I searched the discussions and have not read about it. If it's been discussed, please direct me to the existing discussions.

    HI,
    Not sure if this is what you are trying to do but have you tried Spotlight? Make sure your Spotlight search criteria is set up correctly first.
    Open System Preferences / Spotlight. Make sure Webpages is selected.
    Carolyn

Maybe you are looking for

  • How to get the "last changed by" for a set of function modules?

    How to get the "last changed by" for a set of function modules? is there any table to get it??

  • Can not see pdf file on desktop

    when i saving from word to pdf on my windows 7 desktop is not on the desktop,but when i search for the file an check the file location it show it's on desktop can any one help me to solve this problem 

  • Monitor and record server performance

    Hi all. This is not really Arch related but a general question. I have a web server that has services crashing. I think it may be due to low mem. Is there any software or some method that would allow me to monitor/log server stats/performance and the

  • R12 Database not starting

    hi , when im trying to start the database in R12 instance im getting the following error... im using redhat limux server version 4.0.... ORA-00600: internal error code, arguments: [2252], [2249], [688368325], [], [], how can i solve this.??.. thanks,

  • About [notifyOnDataChangedObservers]

    i found a error at 985 line in "SpryData.js " file. the code: quote: selfClosureRef.notifyOnDataChangedObservers(selfClosureRef, Spry.Data.DataSet.ODC_DataChanged); the method just have one parameter.the second "selfClosureRef" ought to remove.