Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • The question, I accept might be similar. But one of the answers listed below here by @nsg is very interesting and novel. I am yet to try this solution out and rate it. I think this might work better than using aliasing cd although this is my personal opinion. Thanks for your comment though. Commented Jul 10, 2012 at 15:57
  • 4
    Depends on your goal. The PROMPT_COMMAND based solution will run the command after each command executed inside the specified directory. So if you do cd ~/repository/foo/, du -sch and date, then set_foo_env.sh will be executed 3 times. The cd aliasing solution will execute it only once. Commented Jul 10, 2012 at 16:22