Visit Our UNIX and Linux User Community


set prompt = pwd


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers set prompt = pwd
# 1  
Old 12-01-2010
set prompt = pwd

Assume that you want to set your prompt to display the current working directory followed by a percent symbol and then a space. The command pwd can be used to display this information, so explain why the following command does not have the expected result:

set prompt=" `pwd`'%' "

Its a review question im having trouble on.
# 2  
Old 12-01-2010
The variable that controls your prompt is PS1, not prompt. By using double quotes pwd gets executed immediately during the assignment so it will never change afterwards.
# 3  
Old 12-01-2010
That is c shell syntax, so the variable prompt is ok - Scrutinizers other explanation is correct.
Lets hope you are never forced to use that awful shell after the review...
# 4  
Old 12-01-2010
The variable that controls your prompt is shell dependent, PS1 with most shells but prompt for csh and derived ones.

The is no way to display your current directory in the prompt with the original csh but with tcsh, that would be:

Code:
set prompt="%/ % "

or better
Code:
set prompt="%~ % "

+1 for cero comment about csh being awful.
# 5  
Old 12-01-2010
Thanks for your guys help.

---------- Post updated at 03:27 PM ---------- Previous update was at 03:24 PM ----------

When you type a command, the shell checks several places to see if it can find a command with that name to run. I need to put the following in the order that the shell checks by default. If the shell does not check it by default I need not include it it.

___ All directories in $path
___ All directories in $PATH
___ Hash table created from $path
___ Current directory
___ Built in commands
___ History list
___ System root directory
___ Alias list
___ Shell variables
___ Your home directory
# 6  
Old 12-01-2010
Is this homework?
# 7  
Old 12-01-2010
It's are part of a review. Finals are next week. It over 200 questions long.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #465
Difficulty: Medium
A 2017 security audit of three NTP implementations, conducted on behalf of the Linux Foundation's Core Infrastructure Initiative, suggested that both NTP was less secure than Chrony.
True or False?

10 More Discussions You Might Find Interesting

1. 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

2. AIX

sync samba pwd with aix5.3 pwd

currently, my samba login works just fine. i want my clients to use aix5.3 account to login to samba so they don't have to change samba pwd and aix pwd. i googled, and vi /usr/lib/smb.conf per some of knowledge base, but i could not get to work. aix5.3 and samba 3.0.24.0 thanks in advace..... (2 Replies)
Discussion started by: tjmannonline
2 Replies

3. Shell Programming and Scripting

tcsh/csh: set prompt in production to color red

Hi folks This is our prompt at the moment oracle@pinkipinki:/opt/oracle> grep 'set prompt' .cshrc set prompt = "$user@`uname -n`:$cwd> " We wish to have in production the same prompt, but red. Howto do that? I tried a lot a internet manuals, but it doesn't work. (1 Reply)
Discussion started by: slashdotweenie
1 Replies

4. Shell Programming and Scripting

CWD in prompt only showing the directory when set

Hi Gurus, I am working in tcsh and i set the prompt with this. set prompt = "$cwd>" But I see teh prompt only gets reflected with the directory where I set the prompt. After i cd to another directory it still shows the old directory. Please advise (1 Reply)
Discussion started by: kinny
1 Replies

5. Shell Programming and Scripting

set timeout for ssh prompt

Hi all, I want to set a timeout say 10 sec to shh prompt i.e. if no password is enetered for 10 sec prompt should again come to shell. How can this be achieved ?? I am using Linux RHEL 5 and Solaris 10. Pls help. Thanks in adv. VIKAS (3 Replies)
Discussion started by: vikas027
3 Replies

6. UNIX for Advanced & Expert Users

echo ${PWD#${PWD%/*/*}/}

Can anyone explain this in detail ... echo ${PWD#${PWD%/*/*}/} Thanks in Advance (1 Reply)
Discussion started by: sakthi.abdullah
1 Replies

7. UNIX for Dummies Questions & Answers

Set prompt, problems and tricks

I'm using a csh shell (or, that'd be my guess from the .cshrc file I see) and I'm looking to change my prompt. There are about 10 other threads, I know, but this question is a little more specific. I want to know, is there a way to list the current directory from a certain level or directory... (6 Replies)
Discussion started by: HybridLogic
6 Replies

8. UNIX for Advanced & Expert Users

"Set prompt"

Hi Currently amending my bash profiles, there is a command that makes my session jump into another location. I just wonder if I could pre-define my prompt to begin with "cd " from this location (in order to navigate further into sub-directories). Is there any way of doing that? An important thing... (0 Replies)
Discussion started by: Indalecio
0 Replies

9. UNIX for Dummies Questions & Answers

set prompt in sh

hi, this < setprompt 'set prompt="# "' > is set in C shell. what is the equivalent in sh? thanks (14 Replies)
Discussion started by: yls177
14 Replies

10. UNIX for Dummies Questions & Answers

kill, set prompt

ok, there is a way to nicely kill a suspended job and to terminate another without using the mass -KILL command. also, how can I set my prompt temporarly without using the .bash_profile that uses the PS1. Thanks:) (1 Reply)
Discussion started by: bitwize
1 Replies

Featured Tech Videos