1

So I've created a bash script that takes argument and then (I want it to) cd me into a directory.

It's not quite a case of cd /home/$1 for example, it's a bit more complex.

The problem is (as I knew it would be) it's cding the sub process rather than my instance of bash.

Is there any way to apply it to my open bash?

joedborg
  • 17,651
  • 32
  • 84
  • 118
  • 1
    Possible duplicate of http://stackoverflow.com/questions/874452/change-current-directory-from-a-script and http://stackoverflow.com/questions/255414/why-doesnt-cd-work-in-a-bash-shell-script – Mark Longair Aug 25 '11 at 09:32
  • Can you paste the relevant part of your script? – Mu Qiao Aug 25 '11 at 09:32

2 Answers2

1

Echo the desired directory, then create a bash alias as follows:

alias jump="cd $(myscript.sh)"

It's the approach I use for autojump, and it works very well.

static_rtti
  • 53,760
  • 47
  • 136
  • 192
0

I guess this is another option for you

favorite directory

TheOneTeam
  • 25,806
  • 45
  • 116
  • 158