Newbie Shell Question

buc99

Don't Tread on Me!
how do I write a script that will "pushd" my shell from it's current directory to a new directory? for instance, I tried the following:

#!/bin/sh
pushd /User/username/bin

What I got was the listing of directories in the stack but I was still in the original directory. I want the shell to change to the new directory so that I can edit something and then use popd to get back where I started.

Thanks.:D
SA
 
You could perhaps source the script to have it affect your current environment:

source script # for [t]csh
. script # for [ba/k]sh

I just tried it and that works. The problem you have when you try to execute the script normally is that it starts a new shell and any changes are done in there, and when the script exits you are back in your original shell.

Unix shells are so powerful but can be very confusing and difficult to get your head around.

Cheers,

Brooke
 
If you want it at login time, write it into "~/.login", else it is easiest to set an alias:

alias pu 'pushd /User/username/bin'
alias po popd

The task is to small to write a script for it.
 
I'm completely useless... I've download and installed Fink but what do i need to install next if i want KDE to run? and if possible have Konqueror on my mac too.

:stupid:
 
fink list kde # good place to start and then do...
fink install ? # for whatever it is you want to install

(Don't forget to follow the install instructions and modify your .tcshrc file to source /sw/bin/fink.tcshrc or whatever it is.

Do a:
fink self-update # every now-and-then to keep the lists current
 
Back
Top