Solved

Appending the "pwd output" to the Primary prompt

Posted on 2001-09-05
9
266 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Centos Boot Error 42 122
Expect & sshpass package for Solaris 10 x86 15 924
Linux : Booting Error after restoring image from OLD PC 23 89
Error while installing rpm 1 84
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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