TIP_Prompt_Magic
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
Contents |
General Information
The first thing we need to know, is which files actually affect the prompt. The section INVOCATION in man bash contains this information, but to summarise: the following files are sourced by default (at least in one invocation method):
- /etc/profile
- ~/.bash_profile
- ~/.bash_login
- ~/.profile
When making changes, try to keep things clean, by keeping everything in the most central file (in this case it is /etc/profile). References in other files can be deleted or at least moved (just to be sure we can easily recover the defaults). It may be useful, however, to keep this information in ~/.bash_profile in case you want to port your settings across to a remote server that you don't have root access to. To see just what is possible, take a look at Ray's Prompt. His method is useful if you want things to just work without too much fiddling.
Ray's Prompt
I've created a prompt that supports some emerge magic for the root user. Most everything about the system that users have wanted can be displayed in the prompt. Email pagerc@gmail.com for any questions, comments, or errors.
- Prompt Code - (prompt)
- Prompt Config - (prompt_config)
- ZSH Prompt Config - (prompt_config *currently broken, but getting closer)
- Prompt Functions - (prompt_functions)
The below links are broken still, when I return fidget.homeip.net to an online status, I'll make these links unbroken
- Prompt Code - (prompt)
- Prompt Config - (prompt_config)
- Prompt Functions - (prompt_functions)
Features:
- User modifiable colors.
- Extensive dynamic color modification of the prompt based on system events.
- Support for APM/ACPI temperature/battery life.
- Support for displaying currently emerging applications (supports multiple parallel emerge notifications).
- Directory information (size of files, #files, #hidden files, #directories, #hidden directories, #executables, #pipes, #sockets)
- Process information (number of processes, 1 minute system load)
- Path truncation, path is truncated to not extend past 50% of your shell.
- Username is colored for root/user to differentiate them.
- Hostname changes color based on system load.
- Path name changes color based on ownership/writability to the directory.
Usage
To use the above prompt, merely source it from the command line. There are currently three files in the distribution of the prompt. I have moved all configuration for options/colors to prompt_config. If your prompt has no colors, make sure that you have prompt_config as ~/.prompt_config. All of the logic that does the prompt magic resides in prompt_functions. If you are getting broken function calls, make sure that you have prompt_functions as ~/.prompt_functions. If you want to get nitty gritty with the ordering of your prompt items, modify prompt, there should be a list of all the bash expansions and some decent comments inside.
| Code: |
$ source prompt |
| File: ~/.bashrc |
# Somewhere towards the end of this file add # If prompt is readable, source it [ -r ~/.prompt ] && . ~/.prompt |
Helpful Links
- Daniel Robbins "Prompt Magic" - prompts, color, xterms
- TLDP.org In-Depth Guide
- Fancy Bash - A good useful prompt
- Bash Prompt Howto - The definitive resource for bash prompts
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.
