Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

Bash Prompt HOWTO

$Revision: 0.93 $, $Date: 2003/11/06 02:12:02 $

Giles Orr

Creating and controlling terminal and xterm prompts is discussed, including incorporating standard escape sequences to give username, current working directory, time, etc. Further suggestions are made on how to modify xterm title bars, use external functions to provide prompt information, and how to use ANSI colours.


Table of Contents
1. Introduction and Administrivia
1.1. Introduction
1.2. Revision History
1.3. Requirements
1.4. How To Use This Document
1.5. Document Versions, Comments and Suggestions
1.6. Problems
1.7. Credits/Bibliography
1.8. Disclaimer
2. Bash and Bash Prompts
2.1. What is Bash?
2.2. What Can Tweaking Your Bash Prompt Do For You?
2.3. Why Bother?
2.4. The First Step
2.5. Bash Prompt Escape Sequences
2.6. Setting the PS? Strings Permanently
3. Bash Programming and Shell Scripts
3.1. Variables
3.2. Quotes and Special Characters
3.3. Command Substitution
3.4. Non-Printing Characters in Prompts
3.5. Sourcing a File
3.6. Functions, Aliases, and the Environment
4. External Commands
4.1. PROMPT_COMMAND
4.2. External Commands in the Prompt
4.3. What to Put in Your Prompt
5. Saving Complex Prompts
6. ANSI Escape Sequences: Colours and Cursor Movement
6.1. Colours
6.2. Cursor Movement
6.3. Xterm Title Bar Manipulations
6.4. Xterm Title Bars and Screen
6.5. Colours and Cursor Movement With tput
7. Special Characters: Octal Escape Sequences
8. The Bash Prompt Package
8.1. Availability
8.2. Xterm Fonts
8.3. Changing the Xterm Font
8.4. Line Draw Characters without VGA Fonts
9. Loading a Different Prompt
9.1. Loading a Different Prompt, Later
9.2. Loading a Different Prompt, Immediately
9.3. Loading Different Prompts in Different X Terms
10. Loading Prompt Colours Dynamically
10.1. A "Proof of Concept" Example
11. Prompt Code Snippets
11.1. Built-in Escape Sequences
11.2. Date and Time
11.3. Counting Files in the Current Directory
11.4. Total Bytes in the Current Directory
11.5. Checking the Current TTY
11.6. Stopped Jobs Count
11.7. Load
11.8. Uptime
11.9. Number of Processes
11.10. Controlling the Size and Appearance of $PWD
11.11. Laptop Power
11.12. Having the Prompt Ignored on Cut and Paste
11.13. New Mail
11.14. Prompt Beeps After Long-Running Commands
12. Example Prompts
12.1. Examples on the Web
12.2. A "Lightweight" Prompt
12.3. Dan's Prompt
12.4. Elite from Bashprompt Themes
12.5. A "Power User" Prompt
12.6. Prompt Depending on Connection Type
12.7. A Prompt the Width of Your Term
12.8. The Floating Clock Prompt
12.9. The Elegant Useless Clock Prompt
A. GNU Free Documentation License
0. PREAMBLE
1. APPLICABILITY AND DEFINITIONS
2. VERBATIM COPYING
3. COPYING IN QUANTITY
4. MODIFICATIONS
5. COMBINING DOCUMENTS
6. COLLECTIONS OF DOCUMENTS
7. AGGREGATION WITH INDEPENDENT WORKS
8. TRANSLATION
9. TERMINATION
10. FUTURE REVISIONS OF THIS LICENSE
How to use this License for your documents