Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-28-2004, 01:00 PM
|
#1
|
LQ Newbie
Registered: Mar 2004
Posts: 7
Rep:
|
altering cd command, can it be done?
This may be more of a unix question, but I'll give it a go anyway. I'm using linux boxes running RedHat 9. the shell - Konsole in RedHat uses bash, knowing this is important.. My goal is to change the command prompt to look alot cooler than I thought the regular one did. I've acheived this:
<MyName><~> 5566#
through changing my .bashrc file at PS1= to say this:
PS1="<MyName><\w> \!# "
\w being current working directory.
This would have been enough, however there is the problem of using the cd (change directory) command. The problem being every time you change directory it prints the working directory. Why is this a problem, because the current directory is already being printed, I really don't need it printed twice. My question is now, can I somehow change the cd command to not print the working directory? Thanks in advance for responses
Last edited by glingon; 10-29-2004 at 07:48 AM.
|
|
|
10-28-2004, 01:09 PM
|
#2
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
That's not a problem with your cd command nor can it be fixed, as it has no idea what type of PS? type input you've customized for yourself. I don't know an easy way around this but it sounds like this would still be a hack for your PS1 environment setting for your user.
|
|
|
10-28-2004, 01:11 PM
|
#3
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
kshell? you mean ksh? ksh doesn't use bash... they are both shells, they don't use each other. and cd in bash doesn't print the current directory.
|
|
|
10-28-2004, 01:18 PM
|
#4
|
Senior Member
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142
Rep:
|
If you comment out the PS1= line in your .bashrc, and re-login, does it still print the pwd?
I can only think it is something else that is doing it. Do you have an alias for cd? Do you have a script named cd somewhere in a directory in your path?
|
|
|
10-28-2004, 02:23 PM
|
#5
|
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908
|
Perhaps a thorough read of the bashprompt howto would give you ideas of how to customize the prompt.
|
|
|
10-29-2004, 07:47 AM
|
#6
|
LQ Newbie
Registered: Mar 2004
Posts: 7
Original Poster
Rep:
|
Still need help
Sorry about the thing about Kshell, i was just looking at the window title Shell - Konsole and thats what came out. I've overviewed the bashprompt howto and it doesn't look like it's going to help me.
My main question here is with the cd command. I've still not found a way to alter this so that it doesn't print the working directory on the next line after you type the command. Someone posted that cd does not do this, but I'm sitting here right now changing directories and its printing the working directory after I use cd.
Any direction would be great.
|
|
|
10-29-2004, 08:11 AM
|
#7
|
Member
Registered: Nov 2000
Location: Hermon, ME
Distribution: slackware
Posts: 201
Rep:
|
type 'alias' at the command line and see if cd has an alias that is doing this. Some distros will do this to make them more user friendly. Like some will have 'rm' alias as 'rm -i' so that it always asks if your sure you want to delete the file.
|
|
|
10-29-2004, 09:29 AM
|
#8
|
LQ Newbie
Registered: Mar 2004
Posts: 7
Original Poster
Rep:
|
Nope, cd itself does not have an alias, however... that may be the solution to my problem, could anyone help me with creating and alias for the cd command that does not pwd?
|
|
|
11-01-2004, 03:04 PM
|
#9
|
LQ Newbie
Registered: Mar 2004
Posts: 7
Original Poster
Rep:
|
Alright, not that you guys don't know any >8 ) . But i went and asked my university unix guru and he gave me the answer. You have to alias the cd command. you use this:
alias cd="cd $1 < /dev/null"
there... its useful.
|
|
|
11-24-2004, 08:47 PM
|
#10
|
LQ Newbie
Registered: Nov 2004
Location: Kwajalein, RMI
Distribution: Fedora, Red Hat Enterprise
Posts: 1
Rep:
|
On Fedora, bash has trouble with alias cd="cd $1 < /bin/null". It can't perform the cd.
On csh or tcsh shells, on SGI unix, the command:
alias cd 'chdir \!* && set prompt="`hostname -s`:${LOGNAME}:`dirs`>'
works to give a prompt like Compter2:JJ:/home>
The prompt can be edited to give any combination of information the user wants to see. The ability to do this is facilitated by having the synonym for cd (chdir) in the builtin commands for the shell. This allows overloading the cd command. In bash, that is harder to do. cd does not normally print the directory again. You may have an overriding alias or two happening.
Hope this helps.
|
|
|
All times are GMT -5. The time now is 01:47 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|