LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 12-21-2009, 10:14 AM   #1
TiredOfThis
Member
 
Registered: Oct 2007
Posts: 50

Rep: Reputation: 15
Bash printing pwd after cd now that I set CDPATH


Hi all,

I set my CDPATH variable in .bashrc. Now, whenever I cd into a directory, bash will print the full path of the directory I just cd'd into.

Example:
Code:
[nathanb@nathanb-box ~] cd doc
/u/nathanb/doc
[nathanb@nathanb-box ~/doc] cd spec
/u/nathanb/doc/spec
[nathanb@nathanb-box ~/doc/spec]
This is annoying and redundant. Is there any way to make it not do that (apart from editing the source myself, obviously)?

Thanks!
 
Old 12-21-2009, 10:44 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
This seems to do the trick, might be worth a whirl
Code:
function my_cd {
    \cd "$@" >/dev/null
}
alias cd='my_cd'
 
Old 12-21-2009, 11:50 AM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by TiredOfThis View Post
This is annoying and redundant. Is there any way to make it not do that (apart from editing the source myself, obviously)?
Why don't use just use the features of the PS1 prompt:

Code:
export PS1='[\u@\h \w] '
will give you a prompt identical to what you are currently displaying in your post.
 
Old 12-21-2009, 12:10 PM   #4
TiredOfThis
Member
 
Registered: Oct 2007
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by David1357 View Post
Why don't use just use the features of the PS1 prompt:

Code:
export PS1='[\u@\h \w] '
will give you a prompt identical to what you are currently displaying in your post.
That's what my PS1 is set to. However, bash ALSO chooses to display the pwd after each cd when CDPATH is set.
 
Old 12-21-2009, 12:38 PM   #5
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by TiredOfThis View Post
That's what my PS1 is set to. However, bash ALSO chooses to display the pwd after each cd when CDPATH is set.
From the bash man page:
Code:
    If a non-empty directory name from CDPATH is used, or if - is the
    first argument, and  the  directory change is successful, the
    absolute pathname of the new working directory is written to the
    standard output.
So this is the expected behaviour. If you want to supress the output, you will have to use something like the hack catkin suggested.
 
Old 12-21-2009, 02:15 PM   #6
TiredOfThis
Member
 
Registered: Oct 2007
Posts: 50

Original Poster
Rep: Reputation: 15
I'm still hoping I can dig up some .bashrc config setting that will let me suppress this, but it's starting to look like the hack is the only way to go.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Script combination of sed with pwd command escaping slashes HaukeG Programming 2 10-06-2009 04:04 AM
bash: PWD minus last two directories wonderfullyrich Programming 4 09-11-2009 05:32 AM
Bash Prompt - display correct $(pwd) tschima Linux - General 2 07-05-2007 07:03 PM
redirecting the output of pwd into konqueror as a url. using bash fiery_ice Linux - Newbie 5 04-05-2006 03:13 PM
getting custom PWD in bash prompt techrolla Linux - Software 2 08-09-2004 12:39 AM


All times are GMT -5. The time now is 05:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration