Hacker News new | ask | show | jobs
by pooriaazimi 4614 days ago
This is the biggest change:

> http://fishshell.com/release_notes.html

> When tab-completing a file, fish will first attempt prefix matches (foo matches foobar), then substring matches (ooba matches foobar), and lastly subsequence matches (fbr matches foobar). For example, in a directory with files foo1.txt, foo2.txt, foo3.txt…, you can type only the numeric part and hit tab to fill in the rest.

This is really brilliant! I always wanted that (without knowing it).

1 comments

I am looking for something that lets me type the first few letters and when I press the arrow-up key then (maybe in combination with another key), it will only offer those items from the history, which match my previous input.

Something like:

Type:

> ssh

press arrow-up:

> ssh larry@google.com

press arrow-up:

> ssh mark@facebook.com

Not sure if that's what you want, but have you tried this in your .inputrc?

  "\e[B": history-search-forward
  "\e[A": history-search-backward
You can also put this in your bashrc:

  bind '"\e[A":history-search-backward'
  bind '"\e[B":history-search-forward'
It's one of the things I always tell people to use since it makes using bash so much easier.
Looks interesting. How would I use that afterwards?
Type, say, 's' and then press your up arrow.
Fish does that by default.
You can do that in bash with ctrl+r:

Type: ctrl+r

Type: ssh

Bash says:

(reverse-i-search)`ssh': ssh dude@somewhere.com

Type again: ctrl+r

(reverse-i-search)`ssh': ssh someoneelse@elsewhere.com

oh-my-zsh[1] does that for me. It's a pretty great function.

1. https://github.com/robbyrussell/oh-my-zsh

The history-beginning-search-backward widget, which is standard to the zsh line editor, does it. You don't need to pull in all of oh-my-zsh.

To use it, I use:

  bindkey "^[[A" history-beginning-search-backward
This seems to have been broken for me unless I add DEBIAN_PREVENT_KEYBOARD_CHANGES=yes to my .zshenv. I'm not sure if it was an update to ZSH, oh-my-zsh, or Ubuntu that causes the issue.
Im using oh-my-zsh, but I cant find this one. Care to enlighten me which option or plugin I should enable? :)

Edit: Seems ctrl-up and ctrl-down does the trick.

I'm using https://github.com/zsh-users/zsh-history-substring-search

It emulates the Fish behavior (which is just awesome). I'm not sure if it requires oh-my-zsh, but I think it doesn't.

It's actually a plugin bundled with oh-my-zsh, but I copy-pasted the default keybindings from the github page you linked, and it's indeed pretty awesome.
Not exactly what you're asking for but: Alt + Up might help.

From the docs: Alt-Up and Alt-Down search the command history for the previous/next token containing the token under the cursor before the search was started. If the commandline was not on a token when the search started, all tokens match. See the history section for more information on history searching. [1]

[1] - http://fishshell.com/docs/2.1/

Up does this by default. Alt+Up is useful for searching a single word through history

I know of three history completion modes in fish.

Full command search: start typing a command and press Up. This will search for entire commands matching your query.

Word search: type any letters in a command, then press Alt+Up. This will cycle only the current word based on a substring match of your query. Useful for hostnames, filenames, etc.

Context-sensitive: If fish 'previews' the rest of a line as a lighter color text, press the right arrow key to complete. This is sensitive to the current directory and available files. If you go into a directory, `touch filename`, `cat filename`, and type `cat`, it will preview `cat filename` for you. Pressing the right arrow key will type it. If you `rm filename` or change directory, `cat filename` will no longer appear.

This is actually the feature of fish I use the most and is the primary reason I always install fish on my servers. Automatic history search using the up-arrow is fantastic.
Ctrl+R.
In my Fedora Linux bash page-up works like that.
fish does this too when you press up arrow key.
bash: "\C-p": history-search-backward in ~/.inputrc
Or in .bashrc:

bind "C-p":history-search-backward

bind "C-n":history-search-forward

This is what the arrow-up key in ZSH does by default.
On my box, zsh only searches based on the first word. Other options, in comments above, search on multi words. For example "git push" then up arrow works expected.
In your ~/.inputrc

"\e[A": history-search-backward

"\e[B": history-search-forward

Tcsh does just that by default (at least on FreeBSD).
I have been doing this for over a decade with csh.
Thanks for all the tips! :)
zsh does that