.bash_profile question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers .bash_profile question
# 1  
Old 03-27-2014
.bash_profile question

Hello everyone,

I'm trying to set my .bash_profile to change my primary prompt from this:

Code:
banbatchtest1v:MCPPRD:~>

to this:

Code:
banbatchtest1v:MCPPRD:/home/rcarvall>

Here's what my .bash_profile looks like right now:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

I'm simply not sure how or where to add the /home/rcarvall or whether I actually need to change something else (i.e. .bashrc) to make this happen.

Just in case, I'm running Red Hat enterprise 6.4.

Will appreciate any feedback on this.

Rob
# 2  
Old 03-27-2014
Look for man bash, and search PS1. It has a tonn of option. But if you are lazy like me, here's the quick one

Code:
export PS1="[\u@\h \w]\$"

Should do what you want. Make sure after this is added to bashrc, to open a new terminal

Here's the options that can be used in PS1 per man bash

Code:
              \a     an ASCII bell character (07)
              \d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
              \D{format}
                     the format is passed to strftime(3) and the result is inserted into the prompt string;
                     an  empty  format  results  in  a locale-specific time representation.  The braces are
                     required
              \e     an ASCII escape character (033)
              \h     the hostname up to the first ‘.’
              \H     the hostname
              \j     the number of jobs currently managed by the shell
              \l     the basename of the shell’s terminal device name
              \n     newline
              \r     carriage return
              \s     the name of the shell, the basename of $0 (the portion following the final slash)
              \t     the current time in 24-hour HH:MM:SS format
              \T     the current time in 12-hour HH:MM:SS format
              \@     the current time in 12-hour am/pm format
              \A     the current time in 24-hour HH:MM format
              \u     the username of the current user
              \v     the version of bash (e.g., 2.00)
              \V     the release of bash, version + patch level (e.g., 2.00.0)
              \w     the current working directory, with $HOME abbreviated with a tilde
              \W     the basename of the current working directory, with $HOME abbreviated with a tilde
              \!     the history number of this command
              \#     the command number of this command
              \$     if the effective UID is 0, a #, otherwise a $
              \nnn   the character corresponding to the octal number nnn
              \\     a backslash
              \[     begin a sequence of non-printing characters, which could be used to embed  a  terminal
                     control sequence into the prompt
              \]     end a sequence of non-printing characters


Last edited by linuxpenguin; 03-27-2014 at 01:22 PM.. Reason: code tags
# 3  
Old 03-27-2014
Thanks for the lead on this LPenguin!

I used your above 'export' statement and tweaked it a little and finally got exactly what I wanted. Here's the revised statement:
Code:
export PS1="\h:$ORACLE_SID:$HOME>"

This changed my prompt to:
Code:
banbatchtest1v:MCPPRD:/home/rcarvall>

This mimics what I had in AIX so this works. Thanks again!

Rob
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bash_profile versus bashrc

Hi All Please can you tell , what is the difference between bash_profile and bashrc. How to create them? (8 Replies)
Discussion started by: fretagi
8 Replies

2. Red Hat

.bash_profile file corrupted

Hi, Unexpectedly i entered wrong entries in .bash_profile for my user which has administrative permissions. So, i am getting errors for every command. I dont have backup file also, so any body can help me how to recover it. Regards, Mastan (7 Replies)
Discussion started by: mastansaheb
7 Replies

3. Shell Programming and Scripting

Add Variable in .bash_profile

Hi, I wanted to do the following, but the command does not seem to work. Any ideas or suggestions please help. #1. If the particular ENV variable IMPACT_HOME is not there in a file grep -q IMPACT_HOME infile || sed -i 'i IMPACT_HOME=/my/new/path' infile #2. If the ENV variable... (4 Replies)
Discussion started by: dbashyam
4 Replies

4. UNIX for Advanced & Expert Users

bash_profile or .profile

Hi, happy new year. on AIX 6.1 , for user oracle , there are two files : bash_profile and .profile I do not know which one is executed when login ? How to know , More over in both of them we have : in .profile : ORACLE_HOME=/appli/oracle/product/10.2.0/db_1... (5 Replies)
Discussion started by: big123456
5 Replies

5. Solaris

allias in .bash_profile not working

I am using solaris 10 x86. I have created a .bash_profile under root's home directory(/). The contents of the file are: Solaris10u8/# cat .bash_profile export PATH=$PATH:/usr/sfw/bin export PS1='\h\w\$ ' export PAGER="less -imsq" alias ll='ls -l' alias la='ls -a' The problem is that: ... (7 Replies)
Discussion started by: proactiveaditya
7 Replies

6. Shell Programming and Scripting

Problem in .bash_profile Linux

Hello Friends, I was trying to give a text/welcome message to a specific user just after his login. For that i had added a echo test message line in .bash_profile of that user. Which is not working .... Also i had to execute a script on his login for that i had tried to enter the... (6 Replies)
Discussion started by: NIMISH AGARWAL
6 Replies

7. UNIX for Dummies Questions & Answers

bash_profile does not working

Hi all. when i connect as user megaguru i have a problem my .bash_profile does not working^:( if i do: . ./.bash_profile all enviroment variables are in place. How can i force linux to use .bash_profile before logon process? thanx in advance. (1 Reply)
Discussion started by: smallman
1 Replies

8. Shell Programming and Scripting

question in .bash_profile

We are more users using the oracle account, and people want to include theyr own files in .bash_profile. Like this: while ; do echo -n "LOGNAME is '$LOGNAME' (no sens), who are you? " >/dev/stderr read ln export LOGNAME=$ln done This works well when logging in to... (1 Reply)
Discussion started by: hannem
1 Replies

9. Shell Programming and Scripting

.bash_profile problem

Hi Guys, I modified my .bash_profile script , and tried to change the prompt. Following is the line of code in my .bash_profile script. export PS1=" \W " But I get the output as: \W This appears to be my prompt now. Any idea what should be done.. Thanks! (0 Replies)
Discussion started by: nua7
0 Replies

10. UNIX for Dummies Questions & Answers

numbers on permanently through .bash_profile

Hi Can anyone tell me if it is at all possible to edit ones .bash_profile, to make the setting on of line numbers (in vi/vim), permanent? I've been to a few IRC channels and people keep telling me it is more of a vi/vim thing and to use something called ".vimrc", however I heard that it is... (3 Replies)
Discussion started by: zorrokan
3 Replies
Login or Register to Ask a Question