@@ -36,6 +36,187 @@ Add git-prompt-string to your prompt. For example,
3636PROMPT_COMMAND=' PS1="\[\n \e[0;33m\w\e[0m$(git-prompt-string)\n \e[0;32m\u@local \e[0;36m\$\e[0m \]"'
3737```
3838
39+ ## Configuration
40+
41+ ### Nerd Font
42+
43+ By default, the powerline icon is used as a prefix in the prompt. It is recommended to use a [ Nerd Font] ( https://www.nerdfonts.com/ )
44+ to properly display the (nf-pl-branch) icon. See https://www.nerdfonts.com/ to download a Nerd Font. If you
45+ do not want this symbol, replace the prompt prefix with " ". For example, add the following to you git-prompt-string
46+ configuration.
47+
48+ ``` toml
49+ prompt_prefix = ' '
50+ ```
51+
52+ ### Configuration file
53+
54+ git-prompt-string will first check if the ` --config ` option was passed as an argument. If
55+ ` --config ` is set, the filepath defined in the value will be used as the configuration
56+ file.
57+
58+ If ` --config ` is not set, then git-prompt-string will check if the environment variable
59+ ` $GIT_PROMPT_STRING_CONFIG ` is set. If ` $GIT_PROMPT_STRING_CONFIG ` is set, the
60+ filepath defined in the value will be used as the configuration file.
61+
62+ If ` $GIT_PROMPT_STRING_CONFIG ` is not set, then git-prompt-string will check if the environment
63+ variable ` $XDG_CONFIG_HOME ` is set. If ` $XDG_CONFIG_HOME ` is set, the directory defined in then
64+ value will be used as the base directory for git-prompt-string configurations. See
65+ [ XDG Base Directory Specification] ( https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html )
66+ for more information on XDG environment variables.
67+
68+ If ` $XDG_CONFIG_HOME ` is not set, then ` ~/.config ` and ` ~/AppData/Local ` will be used as the
69+ base directory for Unix and Windows, respectively.
70+
71+ The file defined at ` git-prompt-string/config.toml ` in the base directory will be used to configure
72+ git-prompt-string.
73+
74+ | OS | Base directory | Configuration file |
75+ | :------ | :-------------- | :-------------------------------------------- |
76+ | Unix | ~ /.config | ~ /.config/git-prompt-string/config.toml |
77+ | Windows | ~ /AppData/Local | ~ /AppData/Local/git-prompt-string/config.toml |
78+
79+ If the configuration filepath is set to the special value of ` NONE ` , then all user configurations will
80+ be ignored. For example, ` git-prompt-string --config=NONE ` or ` GIT_PROMPT_STRING_CONFIG=NONE git-prompt-string `
81+ will use the default configuration values defined by git-prompt-string.
82+
83+ ### Configuration options
84+
85+ The following configuration options are available in either as a command-line argument or TOML key.
86+
87+ ``` text
88+ --ahead-format or ahead_format
89+ The format used to indicate the number of commits ahead of the
90+ remote branch. The %v verb represents the number of commits
91+ ahead. One %v verb is required. (default "↑[%v]")
92+
93+ --behind-format or behind_format
94+ The format used to indicate the number of commits behind the
95+ remote branch. The %v verb represents the number of commits
96+ behind. One %v verb is required. (default "↓[%v]")
97+
98+ --color-clean or color_clean
99+ The color of the prompt when the working directory is clean.
100+ (default "green")
101+
102+ --color-delta or color_delta
103+ The color of the prompt when the local branch is ahead, behind,
104+ or has diverged from the remote branch. (default "yellow")
105+
106+ --color-dirty or color_dirty
107+ The color of the prompt when the working directory has changes
108+ that have not yet been committed. (default "red")
109+
110+ --color-disabled or color_disabled
111+ Disable all colors in the color-disabled
112+
113+ --color-merging or color_merging
114+ The color of the prompt during a merge, rebase, cherry-pick,
115+ revert, or bisect. (default "blue")
116+
117+ --color-no-upstream or color_no_upstream
118+ The color of the prompt when there is no remote upstream branch.
119+ (default "bright-black")
120+
121+ --color-untracked or color_untracked
122+ The color of the prompt when there are untracked files in the
123+ working directory. (default "magenta")
124+
125+ --diverged-format or diverged_format
126+ The format used to indicate the number of commits diverged
127+ from the remote branch. The first %v verb represents the number
128+ of commits ahead of the remote branch. The second %v verb
129+ represents the number of commits behind the remote branch. Two
130+ %v verbs are required. (default "↕ ↑[%v] ↓[%v]")
131+
132+ --no-upstream-remote-format or no_upstream_remote_format
133+ The format used to indicate when there is no remote upstream,
134+ but there is still a remote branch configured. The first %v
135+ represents the remote repository. The second %v represents the
136+ remote branch. Two %v are required. (default " → %v/%v")
137+
138+ --prompt-prefix or prompt_prefix
139+ A prefix that is added to the beginning of the prompt. The
140+ powerline icon is used be default. It is recommended to
141+ use a Nerd Font to properly display the (nf-pl-branch) icon.
142+ See https://www.nerdfonts.com/ to download a Nerd Font. If you
143+ do not want this symbol, replace the prompt prefix with " ".
144+ \ue0a0 is the unicode representation of . (default " \ue0a0 ")
145+
146+ --prompt-suffix or prompt_suffix
147+ A suffix that is added to the end of the prompt.
148+ ```
149+
150+ ### Specifying colors
151+
152+ A color value in the configuration must be either a single color or multiple colors
153+ separated by white space.
154+
155+ Valid formats for a color are:
156+ - ` color `
157+ - fg:` color `
158+ - bg:` color `
159+ - #ffffff
160+ - #fg: ffffff
161+ - #bg: ffffff
162+ - ` reset `
163+
164+ The value ` reset ` will clear all text formatting and reset the color to the default value.
165+ Colors starting with ` bg ` or ` #bg ` are background colors. All other formats are considered
166+ foreground colors. i.e., ` red ` is equivalent to ` fg:reg ` .
167+
168+ Colors starting with ` # ` are considered a hex color code and must have 6 digits.
169+
170+ Valid colors are defined in the following table.
171+
172+ | Color | Code |
173+ | :------------- | :-- |
174+ | black | 0 |
175+ | red | 1 |
176+ | green | 2 |
177+ | yellow | 3 |
178+ | blue | 4 |
179+ | magenta | 5 |
180+ | cyan | 6 |
181+ | white | 7 |
182+ | bright-black | 8 |
183+ | bright-red | 9 |
184+ | bright-green | 10 |
185+ | bright-yellow | 11 |
186+ | bright-blue | 12 |
187+ | bright-magenta | 13 |
188+ | bright-cyan | 14 |
189+ | bright-white | 15 |
190+
191+ The following are examples of valid color configurations:
192+
193+ ``` toml
194+ color_clean =' #e5ee04'
195+ color_no_upstream =" reset fg:black bg:white"
196+ color_dirty =" bg:#b30559"
197+ color_delta =" fg:#fcb728"
198+ color_untracked =" fg:#ff0000 bg:#16f2aa"
199+ color_merging =" bg:#ccccff magenta"
200+ ```
201+
202+ ### Default configuration
203+
204+ ``` toml
205+ prompt_prefix = ' '
206+ prompt_suffix = ' '
207+ ahead_format = ' ↑[%v]'
208+ behind_format = ' ↓[%v]'
209+ diverged_format = ' ↕ ↑[%v] ↓[%v]'
210+ no_upstream_remote_format = ' → %v/%v'
211+ color_disabled = false
212+ color_clean = ' green'
213+ color_delta = ' yellow'
214+ color_dirty = ' red'
215+ color_untracked = ' magenta'
216+ color_no_upstream = ' bright-black'
217+ color_merging = ' blue'
218+ ```
219+
39220## 📌 Alternatives
40221- [ git-prompt.sh] ( https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh ) - bash/zsh git prompt support
41222- [ bash-git-prompt] ( https://github.com/magicmonty/bash-git-prompt ) - An informative and fancy bash prompt for Git users
0 commit comments