Displaying the current working directory in prompt


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Displaying the current working directory in prompt
# 1  
Old 07-09-2010
Lightbulb Displaying the current working directory in prompt

Hi,

I want that the prompt that is being displayed (i.e $ sign) should display always the current directory I am working in instead of that $ sign

example:
as we use PS1=patric and the prompt changes from $ to patric OR
if we write the command PS1=`pwd` it will display the current directory but I need to run this command again and again to know where I am.

can you help me in getting to a solution so that whenever I move out of the directory I can see the current working directory in my prompt instead of the $ sign.
# 2  
Old 07-09-2010
# 3  
Old 07-09-2010
It's also depending what shell you use. If bash, checkout the link dr.house postet. There is also a search function for this forum - I saw a thread about PS1 in ksh using that search function.
# 4  
Old 07-09-2010
I use ksh shell. Now can you help?
# 5  
Old 07-09-2010
Now did you read what I wrote? Using the search function of this forum?
# 6  
Old 07-09-2010
There is much confusing advice about changing PS1.

This solution is for "ksh". The type of quotes is very important. It will not work with no quotes or double quotes.

Code:
PS1='$PWD $ '
export PS1

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Current working directory

Hi all, How do I print the name of my current working directory only to screen? Not pwd! For example, if I was in /home/work I am looking for 'work' only (4 Replies)
Discussion started by: jimjam
4 Replies

2. HP-UX

Unable to Set Prompt to current working DIR

HPUX does not recognise \h,\w,\u to display the hostname,working directory and username respectively. So how do i set the PS1 variable to display my current working Directory as my prompt? I also tried PS1=$PWD, But it keeps showing the same directory path as prompt which PWD was holding at... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

3. UNIX for Dummies Questions & Answers

How can I show my "current" directory as the KSH prompt?

Hi All, This is an embarrassingly simple question and couldn't think of "keywords" to search for the answer, but how do I change my UNIX/KSH prompt to show the machine name and my "current" but not "full" directory? For example: if the machine name is "machine" and I'm currently in... (4 Replies)
Discussion started by: chatguy
4 Replies

4. Shell Programming and Scripting

Current working directory in prompt

Can someone tell me how do i set my current working directory in my prompt? Note: I dont want to use env variable PWD and using `pwd` gives me only my home directoy. suggest a different way ? I use /bin/sh thanks!! (3 Replies)
Discussion started by: yesmani
3 Replies

5. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

6. Shell Programming and Scripting

Displaying current user process

When I typed in ps -a I get this: PID TTY TIME CMD 31799 pts/3 00:00:00 vim 31866 pts/3 00:00:00 vim And to check who is currently logged in, I type who Felix Whoals Tada Whoals Lala Whoals How can I get the user process for all current users who logged in?? I think I need to combine... (14 Replies)
Discussion started by: felixwhoals
14 Replies

7. UNIX for Dummies Questions & Answers

Getting current work directory in Command Prompt

How to get the current working directory as part of the command prompt? Every time I chage the folder, my command prompt path shoud change. I am using Korn Shell. Any help is greatly appreciated. (3 Replies)
Discussion started by: MeganP
3 Replies

8. UNIX for Dummies Questions & Answers

How to change current working directory for dbx on UNIX?

How to change current working directory for dbx on UNIX? means I'll run pgm from one directory , but getcwd() should return path which I want to be, which is not d current dir :) (5 Replies)
Discussion started by: login0001
5 Replies

9. UNIX for Dummies Questions & Answers

Listing only directories in the current working directory using the "ls" command

Hello All, I am trying to list only directories in my current directory using the command "ls -d". But the output only contains the default directory "." and doesn't list the rest of the directories in the working directory. Can anyone explain why this is happening (2 Replies)
Discussion started by: igandu
2 Replies

10. Shell Programming and Scripting

current directory as part of the csh prompt

I would like my csh prompt to behave like the linux csh prompt setting done by linux command (set prompt="%n@%m %c]$ ") how do I do that? What I'm trying to do is that I would like to see what directory I'm in by looking at the prompt. I've figured out that %n is like $user, and %m is like... (3 Replies)
Discussion started by: jamesloh
3 Replies
Login or Register to Ask a Question