1HATCH-SHELL(1) User Commands HATCH-SHELL(1)
2
3
4
6 hatch shell – Activates or sends a command to a virtual environment
7
9 hatch shell [OPTIONS] [ENV_NAME] [COMMAND]...
10
12 Activates or sends a command to a virtual environment. A default shell
13 name (or command) can be specified in the config file entry shell or
14 the environment variable SHELL. If there is no entry, env var, nor
15 shell option provided, a system default will be used: cmd on Windows,
16 bash(1) otherwise.
17
18 Any arguments provided after the first will be sent to the virtual env
19 as a command without activating it. If there is only the env without
20 args, it will be activated similarly to how you are accustomed. The
21 name of the virtual env to use must be omitted if using the --temp env
22 option. If no env is chosen, this will attempt to detect a project and
23 activate its virtual env. To run a command in a project’s virtual env,
24 use . as the env name.
25
26 Activation will not do anything to your current shell, but will rather
27 spawn a subprocess to avoid any unwanted strangeness occurring in your
28 current environment. If you would like to learn more about the bene‐
29 fits of this approach, be sure to read
30 ⟨https://gist.github.com/datagrok/2199506⟩. To leave a virtual env,
31 type exit(1), or you can do Ctrl+D on non-Windows machines.
32
33 hatch-use(1) is an alias for this command.
34
35 Options:
36 -s, --shell TEXT The name of shell to use e.g. `bash`. If the
37 shell
38 name is not supported, e.g. `bash -O`, it will
39 be
40 treated as a command and no custom prompt will
41 be
42 provided. This overrides the config file entry
43 `shell`.
44 -t, --temp Use a new temporary virtual env.
45 -py, --python TEXT A named Python path to use when creating a
46 temporary
47 virtual env. This overrides --pypath.
48 -pp, --pypath TEXT An absolute path to a Python executable to use
49 when
50 creating a temporary virtual env.
51 -g, --global-packages Gives created virtual envs access to the
52 global site-
53 packages.
54 -h, --help Show this message and exit.
55
57 SHELL Default shell name (or command)
58
60 ACTIVATION
61 $ hatch env -ll
62 Virtual environments found in `/home/ofek/.virtualenvs`:
63
64 fast ->
65 Version: 3.5.3
66 Implementation: PyPy
67 my-app ->
68 Version: 3.5.2
69 Implementation: CPython
70 old ->
71 Version: 2.7.12
72 Implementation: CPython
73 $ which python
74 /usr/bin/python
75 $ hatch shell my-app
76 (my-app) $ which python
77 /home/ofek/.virtualenvs/my-app/bin/python
78
79 COMMANDS
80 $ hatch shell my-app pip list --format=columns
81 Package Version
82 ---------- -------
83 pip 9.0.1
84 setuptools 36.3.0
85 wheel 0.29.0
86 $ hatch shell my-app hatch install -q requests six
87 $ hatch shell my-app pip list --format=columns
88 Package Version
89 ---------- -----------
90 certifi 2017.7.27.1
91 chardet 3.0.4
92 idna 2.6
93 pip 9.0.1
94 requests 2.18.4
95 setuptools 36.3.0
96 six 1.10.0
97 urllib3 1.22
98 wheel 0.29.0
99
100 TEMPORARY ENV
101 $ hatch shell -t
102 Already using interpreter /usr/bin/python3
103 Using base prefix '/usr'
104 New python executable in /tmp/tmpzg73untp/Ihqd/bin/python3
105 Also creating executable in /tmp/tmpzg73untp/Ihqd/bin/python
106 Installing setuptools, pip, wheel...done.
107 $ which python
108 /tmp/tmpzg73untp/Ihqd/bin/python
109
111 bash(1)
112
113 hatch(1)
114
115 hatch-build(1), hatch-clean(1), hatch-conda(1), hatch-config(1),
116 hatch-env(1), hatch-grow(1), hatch-init(1), hatch-install(1),
117 hatch-new(1), hatch-pypath(1), hatch-python(1), hatch-release(1),
118 hatch-shed(1), hatch-test(1), hatch-uninstall(1), hatch-update(1)
119
120
121
122 Feburary 2022 HATCH-SHELL(1)