问题
VS Code (Windows 10)
What I want to achieve from ps1 script :
- open 4 terminal tabs
- first one run python venv and then run django server
- second one run python venv and then run django shell
- third one run react (yarn start)
- fourth normal powershell for git and other
I created a powershell script that I run from default opened terminal. Now I'd like to open a new terminal tab from first one.
Can I fire a vs code command shortcut (Ctrl+`) or a vs code command palette (Ctrl+Shift+P) from terminal ?
回答1:
Here is how I solved my problem.
I created a VS Code extension and I used the extension API.
// Create a terminal Window
const term = vscode.window.createTerminal("terminal_name");
// Write any powershell command
term.sendText("cd C:\\path\\to\\follow\\");
// Any other command
term.sendText("yarn start");
// Create a second terminal
const secTerm = vscode.window.createTerminal("second_terminal_name");
secTerm.sendText("cd C:\\another\\path\\to\\follow\\");
secTerm.sendText("py manage.py runserver");
// and so one
来源:https://stackoverflow.com/questions/50983314/vs-code-open-new-terminal-from-powershell