def autojump(): """Initializes a virtualenv""" currently_enabled = autojump_enabled() toggle_autojump() if not currently_enabled: click.echo(click.style("Autojump enabled", fg='green')) else: click.echo(click.style("Autojump disabled", fg='red'))
def switch_or_run(cmd, venv_name=None): """Switch or run in this env""" if cmd: return _run(venv_name, cmd) inenv = InenvManager() if not os.getenv(INENV_ENV_VAR): activator_warn(inenv) return else: venv = inenv.get_prepped_venv(venv_name) inenv.clear_extra_source_file() inenv.write_extra_source_file("source {}".format(venv.activate_shell_file)) inenv.write_extra_source_file(override_envars_and_deactivate(inenv.get_envvars(venv_name))) if autojump_enabled(): dir = inenv.guess_contents_dir(venv_name) inenv.write_extra_source_file('cd {}'.format(dir)) click.echo(click.style("Jumping to {}".format(dir), fg='green')) sys.exit(EVAL_EXIT_CODE)
def switch_or_run(cmd, venv_name=None): """Switch or run in this env""" if cmd: return _run(venv_name, cmd) inenv = InenvManager() if not os.getenv(INENV_ENV_VAR): activator_warn(inenv) return else: venv = inenv.get_prepped_venv(venv_name) inenv.clear_extra_source_file() inenv.write_extra_source_file("source {}".format( venv.activate_shell_file)) inenv.write_extra_source_file( override_envars_and_deactivate(inenv.get_envvars(venv_name))) if autojump_enabled(): dir = inenv.guess_contents_dir(venv_name) inenv.write_extra_source_file('cd {}'.format(dir)) click.echo(click.style("Jumping to {}".format(dir), fg='green')) sys.exit(EVAL_EXIT_CODE)