I've been using a custom bash prompt for a few years now, and I figured I'd post it here for whoever wants to copy it. The format of the prompt is basically "[time][host][path]$" I sometimes like to switch between showing a long or truncated path in the prompt. In order to make switching between the two versions, I created a simple function called 'myprompt' which changes the PS1 string based on the command line parameter. An example switching from short to long style is shown below:
[17:07][atlas][bin]$ myprompt --long [17:11][atlas][/usr/local/bin]$
You can use my prompt by putting myprompt.env in ~/ and then adding the following to your .bashrc file:
source ~/myprompt.env myprompt
| Attachment | Size |
|---|---|
| myprompt.env | 1.65 KB |
Comments
Error with stephan_prompt
Your myprompt.env uses stephan_prompt yet the .bashrc example you have provided is "myprompt". It easy to fix but for newbies that might be an issue.
To Fix modify myprompt.env to replace stephan_prompt (two instances) to myprompt.
Other than that it's very nice.
Thx for sharing.