Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do i set up a key binding in fish, so that fish understands not to execute the bindingstring after appending it to commandline but just appending it as string to commandline.

I want to set up a binding that appends | less by pressing i.e. Alt + Y.

It seems that by default fish understands the command to automatically execute.

I.e. When i type ls on commandline and then would press Alt + Y it only should complete the command to look like this ls | less but still not executing it.

i'm trying something like this

bind \ey " \| less"

But fish doesn't accept my syntax

share|improve this question
up vote 2 down vote accepted

To append the |less at the end of the command line it's already a default function in fish, using the Alt-p

You can create a function to do that if you prefer:

function __fish_less
       commandline -i -- "|less"

bind \ey __fish_less

I'm not sure if you need to escape the | make some tests...


Regarding append, the commandline help say:

* -a or --append do not remove the current commandline, append the specified string at the end of it
* -i or --insert do not remove the current commandline, insert the specified string at the current cursor position
* -r or --replace remove the current commandline and replace it with the specified string (default)

So to append instead of inserting a command, I guess you should use -a

share|improve this answer
tried that, good idea, but the problem is also with the function that it seems to "enter" execute at the end of the commandline and automatically executes it. perhaps when i want to make a binding for | grep this shouldn't be directly executed since i still have to add the search string in quotation to the end of the line? – NES Jan 4 '11 at 16:10
updated with (I hope) the solution – tmow Jan 4 '11 at 16:15
thanks, tried it. but get the following error message: insertion mode switches can not be used when not in insertion mode. Also as far as i would understand it this could be a issue with using bind in fish with another option, since it always tries to execute it and not just adds strings to the line? – NES Jan 4 '11 at 16:28
I think you are right. Let's see if anybody else as a solution, otherwise the best is to ask to the guy who developed fish (and then come back here with an answer). – tmow Jan 4 '11 at 16:33
ah, got it working. perhaps you can update your answer, so i will accept them. the problem in your example is the syntax. there are missing quotations, so the shell interprets the commandline in your function as a pipe of two different commands. It have to look like this commandline -a -- "| less" – NES Jan 4 '11 at 20:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.