faho · GitHub

@faho

@faho

ridiculousfish

…ally complete
This means querying when the commandline is in a state that it could
be executed. Because our `execute` bind function also inserts a
newline if it isn't.
One case that's not handled right now: `execute` also expands
abbreviations, those can technically make the commandline invalid
again.
Unfortunately we have no real way to *check* without doing the
replacement.
Also since abbreviations are only available in command position when
you _execute_ them the commandline will most likely be valid.
This is enough to make transient prompts work:
```fish
function reset-transient --on-event fish_postexec
    set -g TRANSIENT 0
end
function maybe_execute
    if commandline --is-complete
        set -g TRANSIENT 1
        commandline -f repaint
    else
        set -g TRANSIENT 0
    end
    commandline -f execute
end
bind \r maybe_execute
```
and then in `fish_prompt` react to $TRANSIENT being set to 1.
As far as I'm concerned that means it:
Fixes fish-shell#7602
"is-complete" sounds like it's about completions
Yeah, this uses `commandline --input`, which is fantastic for this.
2 for incomplete, 1 for error, 0 for okay

@faho

@faho

@faho

faho deleted the commandline-is-complete branch

August 14, 2021 11:08

@faho faho changed the title commandline: Add --is-complete option to query whether it's syntactically complete commandline: Add --is-valid option to query whether it's syntactically complete

Aug 14, 2021

Merged

5 tasks

Merged

5 tasks

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators

Aug 15, 2022

Read the original on github.com ↗