ability to specify command when hitting enter (#1223)

* ability to specify command when hitting enter

* documentation

* man page

* generate man page and html

* run default command through same logic as other commands

impetuous: persist return val for display in promt if non-zero

also future-proofs for other benefits / DRYness. no need for another eval invocation.

* fix generated manpage
This commit is contained in:
John Bachir 2026-01-19 22:11:45 -08:00 committed by GitHub
parent b9bd309a87
commit 6ed2643252
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 2 deletions

View file

@ -392,13 +392,20 @@ Type `exit`, `quit`, or `q` to end the repl session.
Any arguments to git repl will be taken as the first command to execute in
the repl.
You can specify a default command to run when hitting enter:
```bash
git config --global git-extras.repl.on-enter-command "git status -sb"
```
You can configure which character is used at the end of the prompt: (default `>`):
```bash
git config --global git-extras.repl.prompt-character "±"
```
You can specify the prefix for the prompt (default `git`):
You can specify the prefix for the prompt, or remove it (default `git`):
```bash
git config --global git-extras.repl.prefix ""
```

View file

@ -52,7 +52,14 @@ while true; do
# Built-in commands
case $cmd in
ls) cmd=ls-files;;
"") continue;;
"")
on_enter_cmd=$(git config --get --default '' git-extras.repl.on-enter-command)
if test -n "$on_enter_cmd"; then
cmd="$on_enter_cmd"
else
continue
fi
;;
quit|exit|q) break;;
esac

View file

@ -32,6 +32,10 @@ exit|quit|q
.P
Ends the repl session\.
.SH "CONFIGURATION"
You can specify a default command to run when hitting enter:
.P
\fBgit config \-\-global git\-extras\.repl\.on\-enter\-command "git status \-sb"\fR
.P
You can configure which character is used at the end of the prompt (default \fB>\fR):
.P
\fBgit config \-\-global git\-extras\.repl\.prompt\-character "±"\fR

View file

@ -115,6 +115,10 @@
<h2 id="CONFIGURATION">CONFIGURATION</h2>
<p>You can specify a default command to run when hitting enter:</p>
<p><code>git config --global git-extras.repl.on-enter-command "git status -sb"</code></p>
<p>You can configure which character is used at the end of the prompt
(default <code>&gt;</code>):</p>

View file

@ -40,6 +40,10 @@ git-repl(1) -- git read-eval-print-loop
## CONFIGURATION
You can specify a default command to run when hitting enter:
`git config --global git-extras.repl.on-enter-command "git status -sb"`
You can configure which character is used at the end of the prompt
(default `>`):