Search:  
Gentoo Wiki

TIP_Prompt_Magic

This article is part of the Tips & Tricks series.
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):

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.


The below links are broken still, when I return fidget.homeip.net to an online status, I'll make these links unbroken

Features:

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

Retrieved from "http://www.gentoo-wiki.info/TIP_Prompt_Magic"

Last modified: Fri, 05 Sep 2008 23:13:00 +0000 Hits: 24,165