Hacker News new | past | comments | ask | show | jobs | submit login

I map <up> to history-search-backward in my .inputrc; so I can type 'sudo ' and press <up> to cycle through everything starting with sudo:

    #  <up>      -- history search backward (match current input)
    "\e[A": history-search-backward
    #  <down>    -- history search forward (match current input)
    "\e[B": history-search-forward
https://github.com/westurner/dotfiles/blob/develop/etc/.inpu...



I do the exact same thing. This will probably be considered sacrilege by some but I also remap tab completion to cycle through all matches instead of stopping at the first ambiguous character:

# Set up tab and Shift-tab to cycle through completion options

"\e[Z": "\e-1\t"

TAB: menu-complete

# Alt-S is normal style TAB complete

"\es": complete


> I also remap tab completion to cycle through all matches instead of stopping at the first ambiguous character

Windows PowerShell does this and I love it. I don’t understand why people wouldn’t want this


Because instead of helping me enter a long filename by its distinctive parts, it forces flat mental read-decide-skip loop based on first few letters, which is slow and cannot be narrowed down without typing out additional letters by hand. It is like selecting from a popup menu through a 1-line window.

If it presented a real popup for file selection, combining both worlds (tab to longest match, untab to undo, up-down to navigate), that would be great. But it doesn’t.


For anyone who isn’t already aware, fzf[0] does this exactly (and more!)

https://github.com/junegunn/fzf


Rust implementation [1]

[1] https://github.com/lotabout/skim


Thanks! Its vim plugin seems very promising.


> which is slow and cannot be narrowed down without typing out additional letters by hand.

In a PowerShell environment specifically, you usually end up having to backspace a dozen or more characters completed from a long command name before you can resume narrowing the search. It's less of a problem on a Unix shell where commands tend to be short.


Interestingly, that's one of the things I hate about powershell (and dos)


zsh works like that too.


I did this a lot, too, until I started using fzf and mapped <Control-r> to fuzzy history search. It is really useful, you might like it!


I came here to post exactly this! Very useful.

Two more quick tips

1. Undo is ^_ (ctrl+shift+-)

2. To learn more tricks...

   bindkey -p


> Undo is ^_ (ctrl+shift+-)

I use ctrl-/. I don't recall whether it's a default binding or not, but at least you don't have to press the shift key :-)


Both are valid undo bindings in emacs so this is probably the reason that they are both supported. (I think this is an arrogant of a time where the keys were indistinguishable (and I think maybe they still are mostly indistinguishable to terminal apps))




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

Search: