mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Improve git-repl prompt (#1224)
* repl config ideas * documentation * Update bin/git-repl Co-authored-by: Edwin Kofler <edwin@kofler.dev> * separator * man page and web docs * always use dir for project name --------- Co-authored-by: Edwin Kofler <edwin@kofler.dev>
This commit is contained in:
parent
6f4cf0c1bb
commit
b9bd309a87
17
Commands.md
17
Commands.md
|
|
@ -392,6 +392,23 @@ 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 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`):
|
||||
```bash
|
||||
git config --global git-extras.repl.prefix ""
|
||||
```
|
||||
|
||||
You can have the name of the current git repo shown in the prompt (default `false`):
|
||||
|
||||
```bash
|
||||
git config --global git-extras.repl.show-project-name "true"
|
||||
```
|
||||
|
||||
```bash
|
||||
$ git repl
|
||||
git version 2.34.1
|
||||
|
|
|
|||
15
bin/git-repl
15
bin/git-repl
|
|
@ -19,7 +19,20 @@ while true; do
|
|||
else
|
||||
es_string=""
|
||||
fi
|
||||
prompt="git$cur_string$es_string> "
|
||||
prompt_character=$(git config --get --default '>' git-extras.repl.prompt-character)
|
||||
|
||||
prefix=$(git config --get --default 'git' git-extras.repl.prefix)
|
||||
|
||||
show_project_name=$(git config --get --default 'false' git-extras.repl.show-project-name)
|
||||
if [[ "$show_project_name" == "true" ]]; then
|
||||
project_name=" $(basename "$(git rev-parse --show-toplevel)" .git)"
|
||||
else
|
||||
project_name=""
|
||||
fi
|
||||
|
||||
prompt_base="$prefix$project_name$cur_string$es_string$prompt_character"
|
||||
prompt_base_stripped=$(echo "$prompt_base" | awk '{$1=$1};1')
|
||||
prompt="$prompt_base_stripped "
|
||||
|
||||
# Use arguments as a command if any are provided.
|
||||
if [ $# -ne 0 ]; then
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -31,6 +31,16 @@ Equivalent of 'git ls\-files'\.
|
|||
exit|quit|q
|
||||
.P
|
||||
Ends the repl session\.
|
||||
.SH "CONFIGURATION"
|
||||
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
|
||||
.P
|
||||
You can specify the prefix for the prompt (default \fBgit\fR): \fBgit config \-\-global git\-extras\.repl\.prefix ""\fR
|
||||
.P
|
||||
You can have the name of the current git repo shown in the prompt (default \fBfalse\fR):
|
||||
.P
|
||||
\fBgit config \-\-global git\-extras\.repl\.show\-project\-name "true"\fR
|
||||
.SH "EXAMPLES"
|
||||
.nf
|
||||
$ git repl
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html;charset=utf8'>
|
||||
<meta name='generator' content='Ronn-NG/v0.9.1 (http://github.com/apjanke/ronn-ng/tree/0.9.1)'>
|
||||
<meta http-equiv='content-type' content='text/html;charset=utf-8'>
|
||||
<meta name='generator' content='Ronn-NG/v0.10.1 (http://github.com/apjanke/ronn-ng/tree/0.10.1)'>
|
||||
<title>git-repl(1) - git read-eval-print-loop</title>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: man */
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#COMMANDS">COMMANDS</a>
|
||||
<a href="#CONFIGURATION">CONFIGURATION</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
|
|
@ -112,6 +113,21 @@
|
|||
|
||||
<p>Ends the repl session.</p>
|
||||
|
||||
<h2 id="CONFIGURATION">CONFIGURATION</h2>
|
||||
|
||||
<p>You can configure which character is used at the end of the prompt
|
||||
(default <code>></code>):</p>
|
||||
|
||||
<p><code>git config --global git-extras.repl.prompt-character "±"</code></p>
|
||||
|
||||
<p>You can specify the prefix for the prompt (default <code>git</code>):
|
||||
<code>git config --global git-extras.repl.prefix ""</code></p>
|
||||
|
||||
<p>You can have the name of the current git repo shown in the prompt
|
||||
(default <code>false</code>):</p>
|
||||
|
||||
<p><code>git config --global git-extras.repl.show-project-name "true"</code></p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<pre><code>$ git repl
|
||||
|
|
@ -150,7 +166,7 @@ git (master)> quit
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>September 2024</li>
|
||||
<li class='tc'>January 2026</li>
|
||||
<li class='tr'>git-repl(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,21 @@ git-repl(1) -- git read-eval-print-loop
|
|||
|
||||
Ends the repl session.
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
You can configure which character is used at the end of the prompt
|
||||
(default `>`):
|
||||
|
||||
`git config --global git-extras.repl.prompt-character "±"`
|
||||
|
||||
You can specify the prefix for the prompt (default `git`):
|
||||
`git config --global git-extras.repl.prefix ""`
|
||||
|
||||
You can have the name of the current git repo shown in the prompt
|
||||
(default `false`):
|
||||
|
||||
`git config --global git-extras.repl.show-project-name "true"`
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue