Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Appending the "pwd output" to the Primary prompt

Posted on 2001-09-05
9
Medium Priority
?
277 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 300 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

885 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