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
  • 16,427
  • 30
  • 80
  • 114
  • 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
  • 50,483
  • 45
  • 130
  • 185
0

I guess this is another option for you

favorite directory

TheOneTeam
  • 24,336
  • 44
  • 110
  • 154