I recently wrote an entry about my bash prompt that made me think about it so much so that I created a new one :D.
This is an short but detailed description of my current bash prompt. The main focus is to highlight important information and conserve display space by keeping the prompt line as short as possible without sacrificing too much information.
Basic prompt functions
Format:
TIME USERALIAS/USERNAME@HOSTALIAS/HOSTNAME CURRENT-DIRECTORY $/#
Time
If more than one terminal is open at one time it can be useful to see when or in which order commands have been executed. The time format is 4 digits (24 hour clock). To conserve space the usual colon infix (:) is omitted.
User alias or name
Either alias to the real user name, otherwise a maximum of 4 characters of the actual user name are displayed.
Host alias or name
Either an alias to the real host name, otherwise a maximum of 4 characters of the actual host name are displayed.
Current directory
The current working directory. The full path is shown until a 25 characters limit has been reached, then only the initial letter of each directory leading up the the last one are displayed.
Last part
$
for a normal user or #
for root prompt.
If the previous command exited with an error the normal user prompt is replaced with ¤%&!
and the root prompt with !!! #
.
Host group, SSH and SSH agent:
USER@HOST DIRECTORY SSH-AGENT-INDICATOR(@)SSH-INDICATOR(ssh) $/#
SSH and SSH Agent indicators
The SSH indicator ssh
is shown after the current working directory when connected though ssh.
If an ssh agent is running the ssh prompt is prefixed with an @
.
Hostname (again)
As seen in the picture above, the host name alias has a red background. This is because the system is identified as a server.
Git/version controlled meta data
Whats going on here?
The git vcs section of the prompt will show you branch name and if there are unstaged or uncommitted changes.
Vcprompt is called if it’s installed to support git/mercurial/subversion, otherwise git’s default prompt functions are used.
The actual prompt code
To use this prompt, paste the following into ~/.bashrc :
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 221 222 223 224 |
|