Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 465  / 2 Years ago, sun, june 5, 2022, 5:02:08

I'm using with and so I have say two different directories say:



~/Development/site1
~/Development/site2


So to set up my enviroment I normally go to ~/Development/site1 then run source bin/activate. Is it possible to have that command run automatically when I cd into one of these directories?


More From » 10.10

 Answers
2

You could put this in your .bashrc to redefine the "cd" command:



cd()
{
[ -z "$*" ] && builtin cd $HOME
[ -n "$*" ] && builtin cd "$*"
[ -f "./bin/activate" && source ./bin/activate
}

[#43350] Tuesday, June 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
icielight

Total Points: 158
Total Questions: 92
Total Answers: 93

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
;