Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also update https://github.com/tj/git-extras/blob/main/man/git-repl.md and generate new man page

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


```bash
git config --global git-extras.repl.on-enter-command "git status -sb"
```

```bash
$ git repl
git version 2.34.1
Expand Down
8 changes: 7 additions & 1 deletion bin/git-repl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ 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
eval "$on_enter_cmd"
fi
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continue will skip exit_status=$? below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before my change, when there was an empty command, the result was continue

after my change, now there is the optional command executed, and then always continue like before

(maybe you know this and are asking something else)

i just now tested the exit_status feature with and without git-extras.repl.on-enter-command being set and it still works

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjb
So the custom command, unlike the command input for prompt, doesn't affect the exit status. Is it intended?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see

i'm not sure if persisting the default commands status would be useful, but i also don't know the use case for normal commands either. so the user knows the exit code just in case different non-0 codes have meaning?

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to make the dfault command also do this

;;
quit|exit|q) break;;
esac

Expand Down
10 changes: 7 additions & 3 deletions man/git-repl.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-REPL" "1" "September 2024" "" "Git Extras"
.\" generated with Ronn-NG/v0.10.1
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
.TH "GIT\-REPL" "1" "January 2026" "" "Git Extras"
.SH "NAME"
\fBgit\-repl\fR \- git read\-eval\-print\-loop
.SH "SYNOPSIS"
Expand Down Expand Up @@ -31,6 +31,10 @@ Equivalent of 'git ls\-files'\.
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
.SH "EXAMPLES"
.nf
$ git repl
Expand Down
13 changes: 10 additions & 3 deletions man/git-repl.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/git-repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ git-repl(1) -- git read-eval-print-loop

Ends the repl session.

## CONFIGURATION

You can specify a default command to run when hitting enter:

`git config --global git-extras.repl.on-enter-command "git status -sb"`

## EXAMPLES

Expand Down