help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Firing a shell function when I change directories


From: Maxim Kupfer
Subject: Re: [Help-bash] Firing a shell function when I change directories
Date: Fri, 7 Dec 2018 08:23:22 -0800

Great, this is very helpful.

As a follow up, I have two different venv directories with their own
activation script paths depending on how the virtual environment was
created. To accommodate both, I used:
source script 1 || source script 2

This is throwing an error though when script 2 should be run, it says: No
such file or directory, but the second script runs fine. How do I make this
silent so that it doesn't give an error?

Thanks, and sorry if this is considered an unrelated follow up.


On Fri, Dec 7, 2018 at 7:42 AM Greg Wooledge <address@hidden> wrote:

> On Fri, Dec 07, 2018 at 07:19:47AM -0800, Maxim Kupfer wrote:
> > I'm trying to automate the activation of my python virtual environment so
> > that whenever I cd into a directory with a virtual environment, it
> > automatically activates. I can already create a function that checks if
> the
> > directory venv is available (and activate if it is), but I can't figure
> out
> > how to make this run after I enter a new directory. Hoping I could get
> some
> > help from this mailing list.
>
> cd() {
>   builtin cd "$@" || return
>   if [[ -d venv ]]; then
>     source whatever
>   fi
> }
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]