Search code examples
fish

what does "commandline -f repaint" in fish shell?


While trying to debug a prompt problem in my fish shell, I read that the nextd-or-forward-word function calls the commandline builtin function with the "-f repaint" arguments.

I simply can't understand what it does.

The documentation for the "commandline -f" says it "inject readline functions into the reader", what does that mean ?

I am not even sure of what is "readline" here. Is it the GNU C library ? Assuming it is, I can't find any mention of "repaint" in the GNU readline documentation.

Can you explain that to me ?


Solution

  • The documentation for the "commandline -f" says it "inject readline functions into the reader"

    In simple terms, it's commands for fish's commandline reader module. (The documentation is a bit jargon-heavy here, yes)

    So commandline -f repaint tells fish to "repaint" the prompt. That means it'll execute the fish_prompt, fish_mode_prompt and fish_right_prompt functions again, and redraw their output.

    In case of nextd-or-forward-word, it does repaint so the prompt's $PWD display gets updated. If it didn't do that, nextd would move you to a different directory, but since you've not executed a normal command in a commandline, the prompt would stay the same. And redrawing after every input isn't tenable because the prompt can take a while.

    Is it the GNU C library ?

    This would be one thing that the GNU "readline" library would do if fish used it. So fish internally uses the term "readline" as well for things that have to do with reading lines, and it's leaking into the docs.