Display Directory path on top


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Display Directory path on top
# 1  
Old 04-24-2013
Display Directory path on top

Hello,
I am using below in my .bashrc to dynamically display user/host/directory information whenever i logged in to my Red hat Linux 64bit OS, BASH shell.
Code:
export PS1=[${LOGNAME}@$(hostname)]'$PWD>'

output:
Code:
[user1@hostname]/dbms/app/oracle/product/11.2.0/dbhome_1>

But i want to display absolute path information to be displayed as shown below with highlighted in some background color(white/black) just absolute path portion of it, please help.

Expected Output:
Code:
/dbms/app/oracle/product/11.2.0/dbhome_1
[user1@hostname]>

Thank you
# 2  
Old 04-24-2013
Nice idea. Long paths often mess up my prompt too.

Code:
export PS1='\[\033[01;32m\]$PWD\[\033[00m\]\n[${LOGNAME}@$(hostname)]> '

Play with the 01;32m to get the colors you want. 01 is bold, 30-37 are foreground colors, 40-47 are background colors, and you can stack them with ;. To get yellow-on-blue I did 01;44;33m

00 just means 'default', so the code before the newline just sets colors back to normal.
This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. UNIX for Beginners Questions & Answers

How to display only the first 5 running process using top in shell scripting?

topfunc() { top } topfunc Here i used the top command inside a function,and i called the function. when executing this bash file i get all the process which are using by the kernel i just want to display only the first 5 running process. is it possible? (7 Replies)
Discussion started by: Meeran Rizvi
7 Replies

4. Shell Programming and Scripting

Method to display a line at the top always, regardless of stdout

Hi Is there way to, say, echo a line and make sure it is always displayed on the first line, no matter what is coming out on stdout? eg: #!/bin/bash clear echo " ...... Internal audit script ......" tar xvf hugefile.tar I'd like to have the " Internal audit script " line to be shown... (2 Replies)
Discussion started by: bludhemn
2 Replies

5. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

6. Shell Programming and Scripting

Display top ten directories by size

Hi, I am new to Unix. I want to display top 10 folders by size. I tried with du -ksl * | sort -nr | head -10 command .But I am getting the following error -bash: /usr/bin/du: Argument list too long Can some one help me. Thanks. (5 Replies)
Discussion started by: Satyak
5 Replies

7. Shell Programming and Scripting

Shell script to display top 5 process (per cpu consumption)

Hello, I have to create shell script being myself real novice in scripting... I was looking on the Internet for some script examples, but I don't have the basic understanding of the shell. I was trying to do something with “ps” command without success. For exemple total number of... (2 Replies)
Discussion started by: mr_awd
2 Replies

8. Shell Programming and Scripting

Help needed removing two top level folders from path

Hi, I am trying to use either awk or sed to drop the first two folders in a path. So if I had path /folder1/folder2/folder3/folder4.... I need to drop folder1&2, so the new path would be /folder3/folder4... If folder1 and folder2 were the same all the time, this would be easy. But... (4 Replies)
Discussion started by: robertinohio
4 Replies

9. Solaris

Top and Prstat display different results for memory

I have a question about the accuracy of prstat. I did a 'prstat -t' and it shows 99% of my memory is occupied by oracle. NPROC USERNAME SIZE RSS MEMORY TIME CPU 194 oracle 343G 340G 99% 86:17.24 56% However, 'top' shows I still have 7762meg of memory free. Memory: 16G real, 7762M... (4 Replies)
Discussion started by: zen03
4 Replies

10. UNIX for Dummies Questions & Answers

How Can I Have Top Display The Top 20 Processes??

how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number. top -n 20 i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies
Login or Register to Ask a Question