[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Where is Bash Prompt Set??



Scott put forth on 2/8/2010 5:21 PM:
> Hi, I'm new to debian, but not to linux. (experimenting with lenny...)
> 
> This is the question I asked myself while seeing various prompts after
> I thought I had customised them. Near as I can tell, there are three
> different scripts which fiddle with the default bash prompt: 
> 
>   /etc/profile
>   /etc/bashrc
>   ~/.bashrc

.bashrc works for me for both root and users.  I used these docs as a spring board:
http://news.softpedia.com/news/How-to-Customize-the-Shell-Prompt-40033.shtml

I don't use desktop Linux.  My Lenny servers are basically headless (KVM).  I
haven't tested these .bashrc's at the console yet.  These bash prompt tweaks
work well within Win32 Putty SSH sessions.  Logging in as me and doing an SU
instantly changes the prompt, and exiting SU back to my user changes the prompt
back to the user's .bashrc prompt.  I have run into only one problem with my
prompts and that is extremely long commands that wrap.  Using up arrow for
previous command gets screwed up for previous wrapped commands.  Other than
that, works great.  I've got root's prompt in all red up to the path which is
standard white, so there's never any doubt I'm in SU.  I've got users' prompts
in green, also with paths in white.  I really like the prompts I came up with.
Also, I've always _hated_ that # for root's prompt, so I killed it and use a $
now.  No need for it since root is now all red. :)

---------------------------------------------------------------------------
[05:53:41][root@greer]~$ cat .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.

# export PS1='\u@\h:\w\$ '
export PS1="$(tput setaf 1)[\T]$(tput setaf 1)[\u@\h]$(tput sgr0)\w$ "
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
# alias la='ls $LS_OPTIONS -lah'
alias la='ls $LS_OPTIONS -lah --group-directories-first'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

CONCURRENCY_LEVEL=3

---------------------------------------------------------------------------
[05:54:18][root@greer]~$ cat /home/stan/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If running interactively, then:
if [ "$PS1" ]; then

    # don't put duplicate lines in the history. See bash(1) for more options
    # export HISTCONTROL=ignoredups

    # enable color support of ls and also add handy aliases
    eval `dircolors`
    alias ls='ls --color=auto'
    alias dir='ls --color=auto --format=vertical'
    alias vdir='ls --color=auto --format=long'

    # some more ls aliases
    alias ll='ls -l'
    alias la='ls --group-directories-first -lah'
    alias l='ls -CF'

    # set a fancy prompt
    # PS1='\u@\h:\w\$ '
    PS1="$(tput setaf 2)[\T]$(tput setaf 2)[\u@\h]$(tput sgr0)\w$ "

    # If this is an xterm set the title to user@host:dir
    #case $TERM in
    #xterm*)
    #    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    #    ;;
    #*)
    #    ;;
    #esac

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc).
    #if [ -f /etc/bash_completion ]; then
    #  . /etc/bash_completion
    #fi
fi

-- 
Stan


Reply to: