What I've done is create an alias for bash, aptly titled '.bash_aliases' in my home directory. Basically what this script does is take the current working directory and display that information in the upper right corner of the window (or upper right corner of the monitor when working in a virtual terminal) and only display the username at the prompt. I found a similar script to this in a book I had purchased some time back that gave me this idea. Whenever you open a terminal (bash), your config file (~/.bashrc) is read. There is usually a loop contained within that file that seems to always be commented out by default;
- Code: Select all
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
If you create this file (~/.bash_aliases), uncomment these lines. This will allow you to modify how your terminal appears, acts, executes, etc.
Here is my .bash_aliases file with comments.
- Code: Select all
#!/bin/bash
# written by: archeryguru2000
# Free Software Foundation, 2009.
#
# The bash script alters the appearance of the user's command line interface by
# changing the titlebar, prompt, and location of current directory listing. This
# script was adapted from a script written in "Linux Desktop Hacks, Tips & Tools
# for Customizing and Optimizing Your OS" by Nicholas Petreley & Jono Bacon (p 42).
#
function prompt_command
{
tput sc # save the current position
let backwash=$(tput cols)-$(echo $(pwd) | wc -m)-2
# backwash is the calculation of the position to place the cursor and write the whole current working directory, back-up 2 more places to include the brackets
tput cup 0 ${backwash} # position the cursor at y=0, x=calculated length
tput setaf 1 ; tput smul # set the foreground color, bold
echo -n "<" # wrap the full path in brackets
echo -n "$(pwd)" # show the path
echo -n ">" # show the closing bracket
tput setaf 2 ; tput rmul # return colors back to preferred
tput rc # return cursor to the saved position
}
PROMPT_COMMAND=prompt_command
GREEN="\[$(tput setf 2)\]"
RED="\[$(tput setaf 7)\]"
NO_COLOR="\[$(tput sgr0)\]"
case $TERM in
xterm*|rxvt*)
TITLEBAR='\[\033]0;\u@\h \007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}$GREEN\u$RED\$$NO_COLOR: "
PS2='> '
OS4='+ '
After creating this file and modifying ~/.bashrc, your CLI will appear similar to the attached image 'just_right.png'.
I hope this is easy to follow and hopefully somebody else can make use of this.
~~archery~~