Bash Prompt HOWTO

$Revision: 0.100 $, $Date: 2009/08/07 02:33:22 $

This release is a Work In Progress!

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.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".


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. 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. Other tput Functionality
6.6. Special Characters: Octal Escape Sequences
6.7. Line Draw Characters without VGA Fonts
7. Fonts
7.1. Xterm Fonts
7.2. Changing the Xterm Font
7.3. Linux Console Fonts
8. Bashish Package
8.1. Availability and Prerequisites
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 Terminals
10. Prompt Code Snippets
10.1. Built-in Escape Sequences
10.2. Date and Time
10.3. Return Status
10.4. Counting Files in the Current Directory
10.5. Total Bytes in the Current Directory
10.6. Checking the Current TTY
10.7. Stopped Jobs Count
10.8. Load
10.9. Uptime
10.10. Number of Processes
10.11. Controlling the Size and Appearance of $PWD
10.12. Making PWD Pretty
10.13. Laptop Power (APM)
10.14. Laptop Power (ACPI)
10.15. Cutting and Pasting the Prompt
10.16. New Mail
10.17. Prompt Beeps After Long-Running Commands
10.18. Finding the Parent Process - OR, "Dealing With 'script'"
11. Example Prompts
11.1. Examples on the Web
11.2. A "Lightweight" Prompt
11.3. Dan's Prompt
11.4. Elite from Bashprompt Themes
11.5. A "Power User" Prompt
11.6. Prompt Depending on Connection Type
11.7. A Prompt the Width of Your Term
11.8. The Floating Clock Prompt
11.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