Search code examples
fish

Clear everything after prompt in fish shell?


I want to make keybinding that simply clears everything I entered after prompt and till the end. The same behavior as what Ctr+c does, but without appending ^C character to the end of current line and newline. Is it doable somehow?


Solution

  • Try this:

    function clear_to_end
      commandline (commandline --cut-at-cursor)
    end
    bind \cc clear_to_end
    

    This sets the command line to the current command line, truncated at the cursor.