I installed the Terminal package in the sublime3, setting in the package:
{
"terminal": "iTerm.sh",
"parameters": []
}
But when I press the command + shift + T buttons together,there is no response,Why?
For iTerm2 on Sublime Text 3 with Bond's terminal package do the following:
In Sublime 3, go to Preferences > Package Settings > Terminal > Settings - User
Paste the following & save:
{
"terminal": "iTerm2-v3.sh",
"parameters": ["--open-in-tab"]
}
Test opening project folder on iTerm2 with cmd + shift + T (Working on Sublime 3 build 3131)
Terminal package site reference:
Download this shell script and add it to your system path with the name iTerm2-v3.sh.
Make sure you have iTerm >= 3.0.4 or even better, latest iTerm2-v3.
Go to Preferences > Package Settings > Terminal > Settings - User. Your settings file should look like this.
{
"terminal": "iTerm2-v3.sh",
"parameters": ["--open-in-tab"]
}
Also, double check your shortcut is not overridden by other command. Hit Cmd+Shift+P and type Terminal: Open
This should work. The iTerm might not get activated, you have to switch to iTerm2 and check if the current folder in Sublime has opened in a new tab in iTerm2.
Hard to say without more information. However, a good way to debug such issues is to look in the console. To open the sublime console, press Ctrl + ` or select View → Show Console from the main menu. Now press the shortcut again and see if some debug message is shown.
If you suspect that something is wrong with the keybinds, you can run view.run_command('open_terminal') from the console. This is the command that is issued on cmd+shift+t (see the config file of the package).
As a side-note. I didn't know this package existed, instead I once wrote a few lines to do exactly this. It can be useful if you want to play around with running a terminal or such yourself.
import sublime_plugin, subprocess
class OpenTerminal(sublime_plugin.TextCommand):
def run (self, edit):
if self.view.file_name():
cwd = '/'.join(self.view.file_name().split('/')[:-1])
else:
cwd = self.view.window().project_data()['folders'][0]['path']
subprocess.Popen(['xfce4-terminal', '--working-directory=' + cwd])
Related
All in title. Also i'm russian and this is Google Translate. I opened the process in Task Manager and went to the file location. There was an error with access denial, but it was solved with the help of Computer Control. But I don't know how to open this particular terminal in vs code. I introduced OpenConsole first.Yes, but it was only a terminal. But that's what I'm interested in.
SCREENSHOT
I think you want to launch the new Windows Terminal from within VS Code.
What you need to do is edit your USER settings.json, and locate the line that associates an editor with the integrated Windows terminal (there are three built-in editors that you can redefine:
Windows (cmd or PowerShell)
Windows Subsystem for Linux (wsl)
Linux (xterm)
):
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
If you REPLACE this by:
"terminal.integrated.shell.windows": "C:\\Users\\<your_user_name>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
... then your Windows Terminal will pop up rather than the cmd integrated console. But it will be in a separate window (not in the VS Code pane); I am not aware of any method on how to start Windows Terminal in integrated mode...
If it is however your intention to replace the usual cmd terminal by a PowerShell, then you can follow the instructions from Fran6.
A more graphical method is go to your existing VS Code terminal, and go to the drop down to select one of multiple terminals you might have launched. Below your existing terminals, there is an option to 'Select Default Shell':
When you select this option, this will take you straight to the options available to change to your preferred integrated shell:
When you now hit the + next to the dropdown, you can accumulate as many shells as you want, of any type that you want; Here is an example of 2 cmd shells, 1 PowerShell, and one wsl shell:
Update (May 2021):
The terminal.integrated.shell.windows setting is now deprecated.
You should add a profile to terminal.integrated.profiles.windows. For example:
terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": "C:\\WINDOWS\\System32\\cmd.exe"
},
"wt": {
"path": "C:\\Users\\<your_user_name>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
},
},
Then set it as default:
"terminal.integrated.defaultProfile.windows": "wt",
To use a different shell in vscode:
Use the shortcut Ctrl + Shift + P on your keyboard or go to view >> Command Palette
Type in:
Terminal: select default shell
From there you can select a powershell terminal instead of the usual command prompt
VSCode Change Default Terminal
Here is a detailed guide. Just changing the value of the object, works unless you're running java and other programming languages. It works well even with the Code Runner extension.
For some reason my VS Code terminal is Powershell instead of cmd.exe. In my Terminal > External: Windows Exec is set to C:\WINDOWS\System32\cmd.exe. However, when I open the Terminal in VS Code I see PS C:...>. Also, in the terminal drop-down I only see powershell as an option.
How do I switch the Terminal to CMD.exe? Or maybe my better option would be to add cmd.exe to the list of available terminals so I can switch between them?
Open File -> Preferences -> Settings
Select User Settings in upper right corner.
Add the following line
"terminal.integrated.shell.windows": "cmd.exe"
Source: https://blog.jongallant.com/2017/02/vs-code-integrated-terminal-powershell-default-change-to-cmd/
To version
First step:
Second step: select the desired option:
Or
"terminal.integrated.defaultProfile.windows": "Command Prompt"
You can use View / Command Palete / Terminal: select default terminal to select from the range of detected terminals. Mine shows PS and cmd.exe which had to be changed as PS is disabled as a security policy in our environment.
In a recent VS Code upgrade the command prompt path in the profile config was updated as well - terminal.integrated.profiles.windows
This article mentioned how you can reset that.
https://dev.to/andrewriveradev/how-to-set-git-bash-as-integrated-terminal-in-vscode-2k31
Open command palette (CMD + Shift + P)
Search "Preferences: Open User Settings (JSON)"
Delete the terminal.integrated.profiles.windows object from the config
Create a new field by typing "" (double quotation key). Inside the quotation type "terminal." a list of options will appear.
Select terminal.integrated.profiles.windows. When you select terminal.integrated.profiles.windows it will be expanded
Add or replace "terminal.integrated.shell.windows": "cmd.exe"
To add onto LeSchlongLong's answer, which is now deprecated, you can simply follow these steps to change the default profile:
Ctrl+Shift+P (Windows) / Cmd+Shift+P (Mac)
Search for "Terminal: Select Default Profile"
Select whichever profile you would like to use
I looked at this link which talks about changing the default command shell in the integrated terminal of Visual Studio Code. I was able to change it to Git Bash using the below setting in the settings.json file. You can open settings.json file by pressing the Ctrl + , or from File → Preferences → Settings menu:
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
There is a + sign in the integrated terminal with the help of which you can have multiple terminals running parallelly as shown in the screenshot below:
I want to load a Git Bash shell in terminal # 1, Windows PowerShell in terminal # 2, and so on. What is the relevant configuration to achieve it?
No need to keep changing your default terminal setting. Install the Shell Launcher extension, configure it, and then ctrl-shift-t to select which terminal you want to open inside of VS Code.
As of June 17 '2018, things have become really smooth in Visual Studio (VS) Code when it comes to changing the integrated command shell. I'm enlisting all the options here:
Select a different command shell on the go - Name of the command shell is itself a command to switch the current command shell to the target command shell. For example, let's say my integrated command shell is currently showing Bash, and I want to switch to PowerShell. Then type powershell command and press Enter. The command shell will change to PowerShell. Similarly it works for all other types of command shells installed in VS Code.
More instances of command shell - Press Ctrl + Shift + `(back-tick). Every time you press the keyboard shortcut combination, a new instance of the command shell will get added.
Change the configuration of default command shell type - Press F1 in Visual Studio Code and type or select Terminal: Select Default Shell as shown in the snapshot below.
Once selected, then choose the default command shell of your choice to change the settings permanently:
In recent version (1.15.0) you can
change the settings, then run the terminal, you've set
then change the settings again and run the another type of terminal by pressing the + sign
and so on...
You can put this in your settings file, and uncomment which one you need.
// 64-bit cmd if available, otherwise 32-bit
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
Click on Arrow then click something like Select template profile
so then , will Open the search bar automatically, so... change by your choice
Terminal profiles is what you are looking for - https://code.visualstudio.com/docs/terminal/profiles. It didn't exist by the time the question was posted and the only solution by that time was the somewhat limited "terimnal.integrated.terminal.xxx" solution.
Example configuration:
"terminal.integrated.profiles.windows": {
"Cmd": {
"path": "C:\\Windows\\System32\\cmd.exe",
"icon": "terminal-cmd"
},
"GitBash": {
"path": "C:\\Program Files\\Git\\bin\\bash.exe", "icon": "terminal-bash",
"icon": "terminal-bash"
},
"PowerShell": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
"icon": "terminal-powershell"
},
},
I want to change the default terminal app used by Visual Studio Code for Mac. I am thinking it is part of preferences or settings json, but unsure.
Here's an example of how to make another terminal the default for VSCode, in this example I've downloaded iTerm2 and copied iTerm2 to Applications.
Code (Menu) > Preferences > User Settings
Edit settings.json "terminal.external.osxExec": "iTerm.app" and "terminal.explorerKind": "external"
Open in Terminal
iTerm is now default terminal launched from VSCode
For those that want to change the default integrated terminal NOT just the external, and add custom themes, show which git branch you are on, and whether or not files need to be staged or committed for example.
Follow these short steps:
Make sure you have these installed:
iTerm2, oh-my-zsh
Install a powerline font (I am using Menlo which is a nice looking and very popular font).
Go here and click on download
Open the file
Click on install font
(Note: without this, vscode integrated terminal will not render themes correctly)
Open the .zshrc file by running this command:
cd ~ ; code .zshrc
Change iTerm's theme to agnoster:
Press ⌘f to open search in the .zshrc file
Type ZSH_THEME
Search until you find the live code, NOT the commented out code :)
Edit the code it so it looks like ZSH_THEME="agnoster"
Save the file
Open vscode settings using shortcut:
⌘,
Inside of vscode settings, you will see two panels. On the right panel paste this:
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline"
Assuming the settings were empty before, it should now look like this:
{
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline"
}
Finished! Enjoy your new pimped out terminal
-(Optional customization)-
If you want your prompt to display something other than your username such as a thunder bolt, like in mine or anything you want
Open agnoster theme by runnning this command:
cd ~/.oh-my-zsh/themes/ ; code agnoster.zsh-theme
Open search by pressing:
⌘f
Paste this in search bar:
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER#%m"
To change your what your prompt displays, edit ONLY this part:
$USER#%m
DO NOT CHANGE this part:
prompt_segment black default "%(!.%{%F{yellow}%}.)
In conclusion, the code should now look something like this:
prompt_segment black default "%(!.%{%F{yellow}%}.) Insert here whatever your heart desires"
(Note: Technically you can change everything about your terminal prompt, but for the sake of keeping this short, and simple we only edited the username part)
None of these answers fully worked for me. Here is what I changed to get it to work:
Select the default shell as zsh:
CMD + SHIFT + P to open up the command palette. Then type Terminal: Select Default Shell. You can then select zsh.
Change the terminal to use iTerm
Change the font family to use Powerlevel10k
Result
I recently changed my terminal in VSCode to ozh, its just 1 step and 1 line.
Open Command Palette using View > Command Palette
( or simply Command + Shift + P )
add the following line to the user settings.
"terminal.integrated.shell.osx": "zsh"
well I know it's so late, but you could just change it by running command
Terminal: Select Default Shell
its so much easier
From visual studio code blog:
// 64-bit cmd it available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\\Windows\\sysnative\\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
Reference: Integrated Terminal
In vscode settings.json add:
"terminal.integrated.profiles.osx": {
"zsh": null
},
No. But you can vote for this feature here: https://visualstudio.uservoice.com/forums/293070-visual-studio-code
I have found the following Sublime command to be really useful since it opens an explorer window at the location of the current file:
{ "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },
What I would love is a similar command that will open a cmd window instead. Ideally at the root project folder, but current file directory would also be fine.
Have read the following question, but can't quite figure out how to use this in a sublime plugin/command:
BAT file to open CMD in current directory
Click the menu preference > Browser Packages in Sublime Text 2.
Create a folder Cmd in the directory opened in step 1.
Create a python file named cmd.py with the following code in the Cmd folder created in step 2.
import os, sublime_plugin
class CmdCommand(sublime_plugin.TextCommand):
def run(self, edit):
file_name=self.view.file_name()
path=file_name.split("\\")
current_driver=path[0]
path.pop()
current_directory="\\".join(path)
command= "cd "+current_directory+" & "+current_driver+" & start cmd"
os.system(command)
Create a file named Context.sublime-menu with the following code in the Cmd folder created in step 2.
[
{ "command": "cmd" }
]
Restart Sublime Text.
Now you can open the Cmd prompt at the current directory in the right-click context menu.
The Shell Turtlestein package also has a command for this.
With that package installed, you can type CTRL+SHIFT+ALT+C
(or CMD+SHIFT+ALT+C on mac) to open cmd/terminal in the current file's folder.
Just to expand on TomCaps answer, you can also open the command prompt at the root project folder (as was requested in the question), by changing step 3 to:
Create a python file named cmd.py with the following code in the cmd folder created in step 2.
import os, sublime, sublime_plugin
class CmdCommand(sublime_plugin.TextCommand):
def run(self, edit):
file_name=sublime.active_window().project_file_name()
path=file_name.split("\\")
current_driver=path[0]
path.pop()
current_directory="\\".join(path)
command= "cd "+current_directory+" & "+current_driver+" & start cmd"
os.system(command)
I was looking for the same thing, except on Mac OS X. I also tried the
Shell Turtlestein package
But I ended up using the
Sublime Terminal package
for the following reasons:
Shell Turtulestein's main purpose is another
Sublime Terminal lets me use iTerm instead of built in terminal
A non-python method.
Go to Menu > Preferences > Browser Packages.
Open the user directory.
Create a new file cmdRunFromDIR.sublime-build and open in Sublime Text.
Paste the following...
{
"cmd": ["C:\\\\Windows\\System32\\cmd.exe", "/C START &"],
"working_dir": "$file_path"
}
The above will open the current folder but if you want the project directory then there's a whole host of different methods here.
Note: That the & after START will then pass on the $file_path variable which can be changed to any of those below. I couldn't see any documentation for this. It was just trial and error on my behalf and makes sense if you think about it. So, if you try to pass "cmd": ["C:\\\\Windows\\System32\\cmd.exe", "/C START & $file_path"] to will get an ERROR if the path has any whitespaces in it.
$file_path The directory of the current file, e.g., C:\Files.
$file The full path to the current file, e.g., C:\Files\Chapter1.txt.
$file_name The name portion of the current file, e.g., Chapter1.txt.
$file_extension The extension portion of the current file, e.g., txt.
$file_base_name The name-only portion of the current file, e.g., Document.
$folder The path to the first folder opened in the current project.
$project The full path to the current project file.
$project_path The directory of the current project file.
$project_name The name portion of the current project file.
$project_extension The extension portion of the current project file.
$project_base_name The name-only portion of the current project file.
$packages The full path to the Packages folder.
For the keyboard shortcut go to Menu > Preferences > Key Bindings and paste the following code. This shortcut is CTRL+C,D.
{ "keys": ["alt+c,alt+d"], "command": "build", "args": { "file": "{packages}/User/cmdRunFromDIR.sublime-build" } }
Add , at the end of this line if it's not the last line in that file.
There's no requirement to restart Sublime Text.
You also access this via Menu > Tools > Build System > cmdRunFromDIR.
Once this is done CTRL+B will run the command also.
Useful links:
See 1st link below for how to run .bat files directly from Sublime Text. Very little modification of the code above.
Build System - Sublime Text 3
In Sublime Text 3, how to have shortcuts for “Build and Run” and “Build only” separately like it was in Sublime Text 2
How to Add a Shortcut for Any Command in Sublime Text
Build Systems – Configuration