Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You'll also like this little bit I yanked from my .inputrc:

  # By default up/down are bound to previous-history and next-history,
  # respectively. The following does the same but gives the extra functionality
  # where if you type any text (or more accurately, if there is any text between
  # the start of the line and the cursor), the subset of the history starting with
  # that text is searched.
  "\C-p": history-search-backward
  "\C-n": history-search-forward


Discovering that you could so such things in .inputrc was a big lightbulb moment for me.

    # not relevant on osx
    #$include /etc/inputrc
    
    $if Bash
        # append a '/' to show a dir is a dir
        set mark-directories on
        set mark-symlinked-directories on
        # no audible or visual bell
        set bell-style none
        # use ls -F style highlights for completion
        set visible-stats on
        # go right to showing multiple options
        set show-all-if-ambiguous on
        # ctrl-p cycles through options
        "\C-p": menu-complete
        "\C-x\C-x": exchange-point-and-mark
        "\ew": copy-region-as-kill
        # easier back and forth by word
        "\C-b": backward-word
        "\eb": backward-char
        "\C-f": forward-word
        "\ef": forward-char
    $endif
    
    # Two silly macros
    #
    # Insert double quotes & set cursor between them
    "\C-x\"": "\"\"\eb"
    #
    # Insert single quotes & set cursor between them
    "\C-x'": "''\eb"


> # silly macros

I get shell access on one of my webhosting companies (DreamHost), so I scp data up to it a lot, but the path is a bit of a pain to type, except for this shortcut:

   # ctrl-d ctrl-h is a mnemonic for DreamHost
  '\C-d\C-h': login@mysite:login/path/to/mywebsite/data  etc.


I did not know you could put conditions in inputrc. Useful.


I haven't gone to much further with it, but it is very handy: http://tiswww.case.edu/php/chet/readline/readline.html#SEC11


Better yet, from gentoo's /etc/inputrc:

    # map "page up" and "page down" to search history based on current cmdline
    "\e[5~": history-search-backward
    "\e[6~": history-search-forward
This way, you have up/down for history traversal, and page up/page down for history searching.

More importantly, and what most people missed out is that, this history searching works on ALL command line interfaces, including bash shell, ipython, and psql.

Seriously, a command line advocate who doesn't know about this can't be serious.


And also, as I learned recently, gdb. That took me by surprise, until I realised that .inputrc does not contain settings for the shell, or any individual CLI program, but for readline.


Yeah, one of the many nice things about fish(the Friendly Interactive SHell) is that it does that automatically.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: