forked from lvv/git-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.txt
221 lines (162 loc) · 8.03 KB
/
index.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// This is raw asciidoc file. The HTML rendered page is at http://volnitsky.com/project/git-prompt
= GIT Prompt
* Repo: httpx://github.com/lvv/scc[GitHub], httpx://bitbucket.org/lvv/scc[BitBucket] +
* License: httpx://www.gnu.org/licenses/gpl-3.0.html[GPL3]
:v-p: http://volnitsky.com/project
:compact-option: compact
== Basic Usage
image:screenshot-prompt-basic.png[basic usage]
Digit [red]*1* on the 3rd line is a `false(1)` exit code. Also on a non-zero exit code
the terminal bell is sounded. The bell is turned off by default (to set softer
terminal bell use `setterm`).
== GIT
Branch and files are colored according to state. "M" stands for master.
image:screenshot-prompt-git.png[git module screenshot]
.Branch and Files Colors
[cols="^3,^3,12",frame="topbot",options="header"]
|================================================================
| *Branch* | *File* | *Meaning*
| [darkblue]#dark blue# | | Clean repo
| [green]#green# | [green]#green# | Modified or new file. Modifications are in index but not in repo yet.
| [darkred]#dark red# | [darkred]#dark red# | Modified and tracked by repo, but modifications not added to index yet.
| [lightblue]#light blue# | [lightblue]#light blue# | Untracked file.
| [red]#light red# | | Detached Head
| [magenta]#magenta# | | In middle of doing something
|================================================================
== Subversion/SVN
image:screenshot-svn.png[svn module screenshot]
SVN module is disabled by default because even on moderate sized working
directories there is a noticeable delay for prompt display. SVN is slower than
GIT. Enable if needed in <<config,config>>
== Mercurial/HG
HG module was developed by Lee Nussbaum `<wln AT scrunch.org>`.
== Additional features
* Battery status (for laptops)
* Background jobs indicator
* Makefile status check
* Order of prompt elements can be changed
== Labels
Labels are visual cues to help figure out what terminal is running what command.
It is a generalization of xterm-title but it differ from xterm-title in that it
can be displayed in other places (on Screen(1) windows titles for example).
Additionally, the label can display currently executed command (when bash prompt obviously
is not displayed). Because such labels have less space than the prompt, instead of the full path
only the bottommost directory is shown.
On screenshot below the labels are highlighted with red ovals.
image:screenshot-labels.png["labels screenshot", width="300", link="screenshot-labels.png"]
The `screen(1)` status line at the bottom of the smaller gnome-terminal is displayed with
following line in `~/.screenrc`:
---------
caption always "%{= kw}%-w%{= bw}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c"
---------
== Simple AutoJump
AutoJump is a python script from Joel Schaerer providing shortcuts for jumping
to directories you once visited. Git-prompt has a built-in, simplified version of
autojump. It is only about 10 lines of bash code (vs original 100+ python
LOC), there is no database. It remembers only directories from the current
session. It selects not the most frequent dir, but the last visited. Matches are done
from beginning of of dir name (not path name).
-----------------
cd /tmp
cd "~/long dir mp3"
cd "~/long dir mp4"
cd /tmp
cd /var/tmp
cd /etc
cd
j t # same as cd /var/tmp
j .*3 # same as cd "~/long dir mp3"
-------------
== Install
Download link:git-prompt.sh[] or get it with GIT:
------------------
git clone git://github.com/lvv/git-prompt.git
---------------
Put the following command at the end of your profile (`~/.bash_profile` or `~/.profile`)
--------------------
[[ $- == *i* ]] && . /path/to/git-prompt.sh
---------------------
There might be your old prompt defined too. You can comment it out.
Some distros also have `/etc/bashrc` or `/etc/bash/bashrc` with distro default
prompt.
== GIT config
GIT-PROMPT requires following GIT's option to be set:
-------------------------
git config [--global] core.quotepath off
git config [--global] --unset svn.pathnameencoding
git config [--global] --unset i18n.logoutputencoding
-----------------------------
== GIT-PROMPT config
[[config]]
Optional. If no config file is found then git-prompt uses defaults.
Defaults are listed in example `git-prompt.conf`. Git-prompt looks (in listed order)
for the config file in the following locations:
* `/etc/git-prompt.conf`
* `~/.git-prompt.conf`
Copy example config `git-prompt.conf`
to any of the above locations and customize as needed.
== Limitations
* cd-ing into something like linux kernel git working directory for the 1st
time (with cold cache) might take up to 10 seconds (that is how long `git status` executes).
Use `vcs_ignore_dir_list` in config if you want to ingnore such dirs.
* Similarly, the make module may induce a noticeable delay in directories with a large and
complex Makefile (because it has to run `make -q' to figure out its build status).
Use `make_ignore_dir_list` in config to ingnore such dirs.
* Because you will be always reminded about dirty repo (not checked-in files),
you will maintain `.gitignore` and commit more often.
* This prompt is most useful if your screen have enough width.
If this is not the case, you might want to disable file list display (`max_file_list_length=0`).
* When prompt is longer than screen-width it wraps to second line. This is always undesirable.
Because of bug in `gnome-terminal` (or `readline` ?) some color escape codes can be visible on second line.
I've reported gnome-terminal bug. Again, you can disable file list display or limit length (`max_file_list_length`).
* By default some terminals display ascii color with maximum color saturation
which makes colored text of different perceptual brightness. This makes it hard to read.
If your terminal colors are configurable, try change it to softer (pastel)
colors.
== Dependencies
Most probably you don't need to install anything because not optional
dependencies are standard unix utils.
* bash (tested with v3.2.33)
* sed
* tput (terminfo)
* tty (core utils)
* grep
* locale (glibc)
* id (core utils)
* cksum (core utils)
* awk
* git (optional)
* svn (optional)
* hg (optional)
* make (optional)
* acpi (optional, for battery module)
== Todo
* httpx://jonisalonen.com/2012/your-bash-prompt-needs-this/[]
* httpx://tldp.org/HOWTO/Bash-Prompt-HOWTO/x810.html[Beep after long running command]
* httpx://briancarper.net/blog/248/[Sync bash history]
* VIM module needs to be moved out of GIT module
include::../volnitsky.com/project/howto-submit-patch.txt[]
Nobody will use git-prompt if there will be delay in prompt display.
Try to avoid use of external commands and
subshells (backticks) in prompt_command_function. It is ok to use
time consuming ops in postconfig which is executed only once.
== Authors
- Leonid Volnitsky (original author) <[email protected]>, http://volnitsky.com
- Niklas Hofer (CWD truncation) <niklas+dev AT lanpartei.de>, httpx://github.com/niklas/[]
- Lee Nussbaum (HG support) <lee.nussbaum AT gmail.com>, httpx://github.com/wln[]
- Albert Vernon http://xenoclub.wordpress.com[]
- Amir Yalon httpx://github.com/amiryal[]
- Martin httpx://github.com/jerrywho[] <JerryWho AT gmx.de>
- Alexander Goldstein (emacs-shell, prompt chars) httpx://github.com/alexg0[]
- Dmitry <uok AT gmx.net> (bash completion)
- Sergey Shepelev <temotor AT gmail.com>
- Robert Wahler <robert AT gearheadforhire.com>
- Gustavo Delfino <gdelfino AT gmail.com>
- Dan Bravender <dan.bravender AT gmail.com>
- Thomas Geffert <thomas.geffert AT arcutronix.com>
- Tibor Simko <tibor.simko AT cern.ch>
- Peter Juhasz httpx://github.com/pjuhasz[]
[bibliography]
.References
- [[[1]]] 'Bash Prompt HOWTO', http://tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html
- [[[2]]] 'BASH Frequently Asked Questions', http://mywiki.wooledge.org/BashFAQ