I would like to automatically have activated my virtual env when I open a BASH shell (via TerminalView) in a project - a solution similar to Pycharms IDE.
My OS is linux-based. I’m using python’s Django in making web-app’s where I use the BASH shell a lot (running the local server, activating Django shell etc.). I use the TerminalView plugin to open a BASH shell. In the BASH shell I type in this to activate my virtual env:
source /home/jesper/code_u/tavler_simple_complex/venv/bin/activate venv
Switching between projects this task is becoming a little heavy for me. I tried to make macro’s in ST3, but it does not work in TerminalView.
I am therefore looking for a solution where the TerminalView knows which virtual env to activate from the settings in the current project. And then activates it automatically when I open a BASH shell.
My ‘.sublime-project’-files and the ‘TerminalView.sublime-commands’-file are looking like this:
‘.sublime-project’-file:
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"python\" -u \"$file\""
}
],
"folders":
[
{
"path": "/home/jesper/code_u/tavler_simple_complex"
}
],
"python_interpreter": "/home/jesper/code_u/tavler_simple_complex/venv/bin/python3"
}
The code snippet for ‘Open Bash shell’ in the’TerminalView.sublime-commands’-file
{
"caption": "Terminal View: Open Bash Terminal",
"command": "terminal_view_open",
"args" : {"title": "Terminal (bash)", "cmd": "/bin/bash -l"},
},
Any suggestions are appreciated