Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Appending the "pwd output" to the Primary prompt

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
infy_geek
Asked:
infy_geek
  • 5
  • 2
  • 2
1 Solution
 
qiang8Commented:
For csh: Add the following lines into your .cshrc file.

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

Cheer.


0
 
infy_geekAuthor Commented:
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
 
packratt_jkCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
qiang8Commented:
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
 
packratt_jkCommented:
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
 
infy_geekAuthor Commented:
Thanks a lot for the help
0
 
infy_geekAuthor Commented:
Thanks a lot for the help
0
 
infy_geekAuthor Commented:
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
 
infy_geekAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now