Is there a way to get the unescaped content of command line in fish? I mean if command line is like ...

$ ls 'foo' "bar"

... the desired output would be ls 'foo' "bar".

The commandline fish command does return the command line but it escapes the content automatically. i.e. ls foo bar.

In the manual I didn't find any switches to suppress this behavior.

Context: I am trying to emulate bash's ctrl-x ctrl-e which allows editing the command line content in an editor. For that I need the unescaped content of the command line.

Any help would be appreciated.

Turns out fish 2.3 fixes the printing behavior and leaves the command-line unescaped. In fish 2.3 commandline -b prints the command-line unescaped.

This does not answer your question I think, but I found this online somewhere

function bind_edit_commandline
    set -l tmp (mktemp /tmp/fish-fc.XXXXXX)
    commandline > $tmp
    eval $EDITOR $tmp
    commandline -r ""
    cat $tmp | while read -l cmd; commandline -a "$cmd" ""; end 
    rm $tmp
end

And I like Altv, so

bind \ev bind_edit_commandline
  • Thank you, but as you mentioned this doesn't solve the escaping problem. – blackwing May 24 '16 at 23:40
  • I haven't looked at the source code but it wouldn't surprise me if this is a problem that can't be solved the way you want. – glenn jackman May 24 '16 at 23:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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