You are not logged in.

#1 2009-06-05 13:31:11

whoops
Member
Registered: 2009-03-19
Posts: 891

[SOLVED]pushd instead of cd (& alias)?

Hi!

Is there any downside to
a) using pushd instead of cd
b) alias it to cd
?

Or can I somehow switch to the last directory with cd (more than one time by "cd -") too?

Also I've never seen a script use pushd/popd, but just in case one does (or uses extended cd features I don't understand) - can I alias it in a way that makes scripts not use it (I'd say no, but maybe there is a solution non the less)?

Maybe I would have to flush the stack from time to time if I did that (although It doesn't take much space, if I don't restart for a few days and compile a lot it might take a little) - or is it imitable on some way? There seems to be no manual entry for pushd / popd and I can't remember/find where I read about it in the first place any more...


thanks!

Last edited by whoops (2009-06-05 15:06:57)

Offline

#2 2009-06-05 14:24:07

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED]pushd instead of cd (& alias)?

in the top of my .bashrc i have

# exit if we're in a script
[ -z "$PS1" ] && return

that way scripts always get a clean environment.  this has it's [dis]advantages depending on your usage.

i have a couple scripts that pushd to a working directory to extract / sed some files then popd back out before finishing the script, it's useful.

i've seen alot of pushd / cd alias/function setups that look quite useful, google should show you.

Offline

#3 2009-06-05 15:06:36

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: [SOLVED]pushd instead of cd (& alias)?

Thx, then I'll keep the '[ -z "$PS1" ] && return' in mind and experiment a little.

Yes, google found a lot of stuff, but a lot of crap too and I wasn't too sure about the quality of the rest (I try to recall how easy it is to google-find tutorials on how to use root as main user the whole time in ubuntu/vista/etc too, whenever I'm about to use scripts / stuff I don't understand that well).

As there hasn't been anyone screaming "Noooo, you will make your *** mess up your ***!!!!" or something like this yet, I guess that one's google-[solved]-able from this point on.

Offline

Board footer

Powered by FluxBB