LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-29-2003, 01:22 PM   #1
exitsfunnel
Member
 
Registered: May 2003
Distribution: RedHat
Posts: 60

Rep: Reputation: 15
Can I make 'cd' behave this way?


Hello,

I'm a pretty new convert from Windows to Linux. In general, I quite like working (I'm a software developer) on Linux but there are a few wrinkles I'm still trying to iron out. One such issue involves navigating directories with 'cd' I often need to move back and forth between several directories each of which is quite deeply nested in separate hierarchies. I'd like to be able to provide the shell (I use bash) with a set of directories such that when I type 'cd foo' if it can't resolve 'foo' to the current directory it will search the list and execute the appropriate command if there is foo relative to one of the entires. Is there already some means to accomplish this? I'm considering writing a shell script but I'd rather not spend the time if the functionality already exists in some form. Thanks in advance for any replies.

-exits
 
Old 08-29-2003, 01:52 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You could create simple alisases eg:
alias cdsrc='cd /usr/local/src'

Then to get to the src dir:
cdsrc
 
Old 08-29-2003, 07:38 PM   #3
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
You're describing the CDPATH environment variable.

Have a look at man bash for more detail.

Lyle
 
Old 08-30-2003, 06:38 PM   #4
exitsfunnel
Member
 
Registered: May 2003
Distribution: RedHat
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks Lyle!

Thanks Lyle, that was exactly what I was looking for. I figured there had to be a way to do it.

-exits
 
Old 08-30-2003, 06:57 PM   #5
devoyage
Member
 
Registered: Aug 2003
Distribution: many
Posts: 37

Rep: Reputation: 15
try cd'ing around and then type:

dirs -v

if you want to go to one of the directories, use:

pushd +n (where n is the the stack number of the dir)

These can be placed in some functions/aliases to make them a little less cumbersome to use.

enjoy
 
  


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
How can I make Murasaki behave like Hotplug for an unkown device? milewis1 Linux - Hardware 1 05-25-2005 01:57 PM
mc doesn't behave in Konsole will103 Linux - Software 0 10-03-2004 11:41 AM
VI & VIM dont behave phoeniXflame Linux - Software 2 07-02-2003 12:40 PM
VI dosnt behave .... phoeniXflame Linux - Software 7 06-22-2003 12:24 PM
Concern about 'Run from CD' distro's davee General 10 05-07-2003 06:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:17 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration