jld@mtuxo.att.com (XMRJ4-J.DALTON) (08/02/89)
Well, Here goes, QUESTION: I have a very long path which is quite tedious to type in every time I wish to visit a certain directory. My question: Is there a way that I can put this path in a file, then execute a shell that will place me in that directory? I tried a couple of things, but to no avail. One puts me there for a breif moment, but "pwd" tells me I never left my current directory. I would greatly appreciate any Helpful answers. Thanks, John Dalton.
dsm@prism.gatech.EDU (Daniel McGurl) (08/02/89)
In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >QUESTION: I have a very long path which is quite tedious to type in > every time I wish to visit a certain directory. > My question: Is there a way that I can put this path in a > file, then execute a shell that will place me in that directory? Well, I tried this on our system, and to get it to work, I created a file containing the instructions cd $HOME/foo/bar then to execute it, I just did a . file It's putting the shell through A LOT of work to do this, but it works. -- Daniel Sean McGurl "He's got to make his own mistakes, Office of Computing Services and learn to mend the mess he makes." Georgia Institute of Technology, Atlanta Georgia, 30332 ARPA: dsm@prism.gatech.edu
davidsen@sungod.crd.ge.com (William Davidsen) (08/03/89)
Your shell probably has CDPATH, so you can put the pathname-1 there. You can also define a symbol at startup: foo=/big/long/ugly/path cd $foo You need to execute the script in the current shell rather than a subshell, so the . command is used in shell. $ cat foo cd /big/local/ugly/path # this is the script $ . foo # this will do what you want QED bill davidsen (davidsen@crdos1.crd.GE.COM) {uunet | philabs}!crdgw1!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
debra@alice.UUCP (Paul De Bra) (08/03/89)
In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >Well, Here goes, > >QUESTION: I have a very long path which is quite tedious to type in > every time I wish to visit a certain directory. > My question: Is there a way that I can put this path in a > file, then execute a shell that will place me in that directory? >... You can put the name in a file, say "f", and then do a cd `cat f` You cannot put the "cd longfilename" in a shell script and execute it as the 'current directory' is only inherited from parent to child, not the other way round. If you have csh you can create an alias to do the job (see `man csh`) If you have one of the newer shells with functions you create a function mycd() { cd longfilename } export mycd If you have an ancient bourne shell you are out of luck. Paul. -- ------------------------------------------------------ |debra@research.att.com | uunet!research!debra | ------------------------------------------------------
glen@astroatc.UUCP (Glen Ecklund) (08/03/89)
In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >QUESTION: I have a very long path which is quite tedious to type in > every time I wish to visit a certain directory. > My question: Is there a way that I can put this path in a > file, then execute a shell that will place me in that directory? The key is to use the '.' command (sh) or 'source' command (csh) to avoid creating a new shell, and execute the cd in the current shell. The way I do it is to have a list of aliases which are set up when I log in, so I can hop around even more easily: alias cdns32 'cd ~/src/dbx/ns32; pwd' alias cdddt 'cd /usr1/NSC/src/cmd/ddt; pwd' alias cdst 'cd ~/src/st; pwd' alias cdpas 'cd ~gsf/comp/src/fe/src/pcfe/src; pwd' Glen
ekrell@hector.UUCP (Eduardo Krell) (08/04/89)
In article <9730@alice.UUCP> debra@alice.UUCP () writes: >You cannot put the "cd longfilename" in a shell script and execute it >as the 'current directory' is only inherited from parent to child Unless, of course, you use the "." command in the shell ("source" in csh) to execute the script in the current shell environment instead of forking a new shell. Eduardo Krell AT&T Bell Laboratories, Murray Hill, NJ UUCP: {att,decvax,ucbvax}!ulysses!ekrell Internet: ekrell@ulysses.att.com
dune@cbnewsl.ATT.COM (Greg Pasquariello) (08/04/89)
>In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >>QUESTION: I have a very long path which is quite tedious to type in >> every time I wish to visit a certain directory. >> My question: Is there a way that I can put this path in a >> file, then execute a shell that will place me in that directory? Although I am unsure of the version number, ksh on my machine at work has a CDPATH variable. It works like PATH, except it is used by cd. If you have ksh, you might investigate this. Greg Pasquariello att!picuxa!gpasq
buck@siswat.UUCP (A. Lester Buck) (08/05/89)
In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >QUESTION: I have a very long path which is quite tedious to type in > every time I wish to visit a certain directory. > My question: Is there a way that I can put this path in a > file, then execute a shell that will place me in that directory? Since no one has mentioned this yet... Why not use the CDPATH variable, available in all System V Bourne shells (at least), which was designed for just this purpose? -- A. Lester Buck ...!texbell!moray!siswat!buck
guy@auspex.auspex.com (Guy Harris) (08/06/89)
>Although I am unsure of the version number, ksh on my machine at work >has a CDPATH variable. It works like PATH, except it is used by cd. >If you have ksh, you might investigate this. This has been in the Bourne shell since at least System V Release 2; I suspect any recent version of the Korn shell would have it also.
dts@quad.uucp (David T. Sandberg) (08/06/89)
In article <9730@alice.UUCP> debra@alice.UUCP () writes: >In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >>QUESTION: I have a very long path which is quite tedious to type in >> every time I wish to visit a certain directory. >> My question: Is there a way that I can put this path in a >> file, then execute a shell that will place me in that directory? > >You can put the name in a file, say "f", and then do a >cd `cat f` >You cannot put the "cd longfilename" in a shell script and execute it >as the 'current directory' is only inherited from parent to child, not >the other way round. > >If you have an ancient bourne shell you are out of luck. ? Why are the respondents seemingly avoiding the way I usually do it when stuck with Bourne shell? Namely, storing the directory path in an environment variable, ala... $ ACE=/usr/local/ace/reports/src/more/useless/nesting; export ACE $ cd $ACE In fact, on machines where I only have Bourne shell to work with (blech), I'll usually set up a number of these things in my .profile to have ready access to my most commonly-used directories in the most expedient fashion. And many of the people I've worked with have done the same thing - I'm quite surprised no one has yet suggested it here. (You could put the 'cd' in the environment variable as well, if you like, but I don't like to get that distant from sensible command lines...) I've never heard of a Bourne shell so primitive that it wouldn't handle this correctly. Or perhaps I've just been lucky? -- David Sandberg "bidibidibidibidi... here's PSEUDO: dts@quad.uucp your flower, Buck" ACTUAL: ..uunet!rosevax!sialis!quad!dts
dansmith@well.UUCP (Dan "Bucko" Smith) (08/08/89)
In article <218@quad.uucp> dts@quad.uucp (David T. Sandberg) writes: >In article <9730@alice.UUCP> debra@alice.UUCP () writes: >>In article <5068@mtuxo.att.com> jld@mtuxo.att.com (XMRJ4-J.DALTON) writes: >>>QUESTION: I have a very long path which is quite tedious to type in >>> every time I wish to visit a certain directory. I'm surprised no one has mentioned this scheme yet: As long as you have a cdpath variable and symlinks... Make a directory in your home, such as ~/.dirs, and put the .dirs directory in your $cdpath. Now, for frequently accessed directories, make a symlink with whatever name you want to use when you want to cd to that directory. For instance, I have "ulb" as a symlink to "/usr/local/bin", "ulu" for "/usr/lib/uucp", "bkups" for "/usr/local/backups".... Allows you to call things what you want! dan -- Dan "Bucko" Smith dansmith@well.sf.ca.us daniel@island.uu.net unicom!daniel@pacbell.com ph: (415) 332 3278 (h), 258 2136 (w) disclaimer: Island's coffee was laced :-) My mind likes Cyberstuff, my eyes films, my hands guitar, my feet skiing...