Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Appending the "pwd output" to the Primary prompt

Posted on 2001-09-05
9
Medium Priority
?
275 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 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
Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 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