Solved

Appending the "pwd output" to the Primary prompt

Posted on 2001-09-05
9
272 Views
Last Modified: 2010-04-21
Hi,

  I want the present working directory to appear everytime the primary prompt is displayed. I guess the way to do this would be to somehow override the command in /usr/bin that displays the primary prompt to do a pwd before it displays the prompt. I`m not able to concretely figure out how to do this. I`m on a solaris5.6 machine,so if u can tell me how to do this, maybe even supply the script itself, that would be aprreciated
0
Comment
Question by:infy_geek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 

Expert Comment

by:qiang8
ID: 6456504
For csh: Add the following lines into your .cshrc file.

set cwd = $home
setenv HOST `hostname`
set prompt=""$HOST":"$cwd" \! : "

Cheer.


0
 

Author Comment

by:infy_geek
ID: 6456520
hi,

  Could u explain how this works. I need to do it in bash. Also, i want the path displayed in the line preceeding the primary point, else it crowds up the line
0
 
LVL 3

Accepted Solution

by:
packratt_jk earned 100 total points
ID: 6458808
you just need to tweak the bash variables,
PS1 is the primary prompt
bash has metacharacters \w (working dir) and \n (newline)

just stick this in .bashrc or .profile:

PS1="\w\n:>"
export PS1
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 

Expert Comment

by:qiang8
ID: 6459281
If you wish to have your prompt appear like this, pls insert ^J into where you want to break.

For example:

PS1="\w:\h ^J \$"

Then your prompt will be something like this:

/bin:hostname
$

Good luck!!!!!!!!!
0
 
LVL 3

Expert Comment

by:packratt_jk
ID: 6462918
yeah, really it's just the \w you are looking for - it's a metacharacter for bash that will interpolate into the working directory.
0
 

Author Comment

by:infy_geek
ID: 6498915
Thanks a lot for the help
0
 

Author Comment

by:infy_geek
ID: 6498916
Thanks a lot for the help
0
 

Author Comment

by:infy_geek
ID: 6637515
hi,

 ii tried out the solution some time back and it dosent seem to work. In case of
 

PS1="\w\n:>"
export PS1

 i get the prompt wn:>

 and in case of

 PS1="\w:\h ^J \$".

  i get something similar but with a j in it. Let me know if i am doing something wrong
0
 

Author Comment

by:infy_geek
ID: 6637517
hi,

 ii tried out the solution some time back and it dosent seem to work. In case of
 

PS1="\w\n:>"
export PS1

 i get the prompt wn:>

 and in case of

 PS1="\w:\h ^J \$".

  i get something similar but with a j in it. Let me know if i am doing something wrong. I am using solaris 5.6
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question