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
Related
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 have a problem with my terminal / VS Code integrated terminal. When I'm changing directory some directories are with a green background and it's annoying. And I don't know how to disable it. I know that in .zshrc I can disable colors in ls with DISABLE_LS_COLORS="true" but this is not working with cd command.
In the default terminal, it is relatively readable, but in VS Code it is unreadable. Any help?
Add the following line to your .zshrc file
export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"
save the file and then run
source ~/.zshrc
You could just change it for vs code and over ride any theme by changing the settings.json file in settings --> search for workbench --> click edit in settings.json under colour customisations. This should override any theme present from any other add-ons or external terminal mods. I have not tested it before with zshrc though.
In the brackets enter something like this:
"terminal.foreground": "#839496",
"terminal.background": "#002833",
"terminal.ansiBlack": "#003541",
"terminal.ansiBlue": "#268bd2",
"terminal.ansiCyan": "#2aa198",
"terminal.ansiGreen": "#859901",
"terminal.ansiMagenta": "#d33682",
"terminal.ansiRed": "#dc322f",
"terminal.ansiWhite": "#eee8d5",
"terminal.ansiYellow": "#b58901",
"terminal.ansiBrightBlack": "#586e75",
"terminal.ansiBrightBlue": "#839496",
"terminal.ansiBrightCyan": "#93a1a1",
"terminal.ansiBrightGreen": "#586e75",
"terminal.ansiBrightMagenta": "#6c6ec6",
"terminal.ansiBrightRed": "#cb4b16",
"terminal.ansiBrightWhite": "#fdf6e3",
"terminal.ansiBrightYellow": "#657b83",
"terminalCursor.foreground": "#839496",
"terminalCursor.background": "#003541"
I want to run two commands at the same time in Git Bash.
webpack -w
node server.js
So i want to split my terminal into two or multiple tabs.
How to split the terminal into multiple views ?
Your requirements are:
Use git bash
Split into 2 or more tabs
You can archive this the following way.
Download Visual Studio Code
Change your integrated terminal to git bash.
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"
Open a new terminal by clicking on Terminal > new Terminal in VS Code top navigation bar.
Split your terminal
Git Bash, won't allow users to split the screen in to two as the features don't exist. The only way is to use alternative or use ConEmu to configure, my personal preference would be Cmder (console emulator) and other options would be Moba Xterm. Cmder is open source and completely free. This would be much easier than configuring ConEmu.
Cmder: http://cmder.net/
MobaXterm: https://mobaxterm.mobatek.net/
To duplicate a GIT bash in windows press Alt + F2.
This opens a new terminal in the same path as the previous.
You can achieve this in Windows Terminal:
https://learn.microsoft.com/en-us/windows/terminal
Windows Terminal Preview can be configured to save your panes layout on close:
https://www.microsoft.com/en-au/p/windows-terminal-preview/9n8g5rfz9xk3
See this post for how to add a Git Bash profile automatically:
https://stackoverflow.com/a/69093260
Other features include:
Set starting directory for Git Bash profile and Defaults
Customise pane theme, colors, fonts, background images (including animated gifs), transparency, cursor shape, 'retro terminal effects' etc
Launch two instances of GIT Bash and press win + → to automatically divide the screen into two halves and select desired programs.
When Iterm2 shows a file name and line number in Mac OS X, can I ⌘-click on the file and have it open in an already open window in Visual Studio Code and position the cursor at the correct line number.
(Asking this question to document the solution)
It looks like you can just select "Open with editor..." in advanced settings > semantic history now
UPDATE - see the newer accepted answer by #csilk for more recent solution
It turns out you can, though it is not entirely obvious.
Go to Iterm2 Preferences > Profiles > (chosse the profile) > Advanced, then in the Semantic History section choose: Run Command, and enter the following:
/usr/local/bin/code -g \1:\2
If that appears to open in a new window then also try changing your Visual Studio Code settings by adding the following to your settings.json, press ⌘, and add in the right hand pane add:
"window.openFilesInNewWindow": false
EDIT - as mentioned in the comments by #BenjaminPasero adding -r to the command line will also force the file to be opened in the last active Code window, e.g.:
/usr/local/bin/code -r -g \1:\2
As an alternative solution you may still use the default configuration of iTerm2 (open files with default app) but adjust the default app for file itself in MacOS.
File -> Get Info -> Open with: ->
and set your app in combobox (also changes may be applied to all type like the following one)
I did not find the configuration in iTerm2 to set the default editor.
However, it turns out there is another solution.Check out the image below.
set default app for *.js file
To edit files from terminal I use subl (for sublime text) in order to edit the file;
example: If i need to edit app.js file I use subl app.js
Is there any way I can set up webstorm to open from the terminal ?
Try in terminal 'wstorm' and 'webstorm'
If the commands don't work you can run in WebStorm: "Tools" -> "Create Command Line Launcher..."
Note: The solution works only for Linux / MacOS
Update January 2016 using Webstorm 11.0.3 on mac os x
There was no option as described in the accepted answer.
Instead, just use the already installed command line binary wstorm designed for this purpose. Location shown below:
If you actually wish to open webstorm and have it load the contents of the current working directory for example, then place a . after the command:
wstorm .
Noted, others had made similar comments in this answers section, and wished to clarify the situation.
In Webstorm 2020.1.2 you need to do it via JetBrains ToolBox Settings. To do that go to JetBrain Toolbox, click on the settings cog, open Shell Scripts and type the path: /usr/local/bin click apply. Go to your terminal, from your project folder type webstorm . Hope this helps.
As suggested by Ali Faris(comment below), if you have an error like this Shell Scripts failed: /usr/local/bin/webstorm (Permission denied): inside of the logs
Jetbrains Toobox -> settings -> show log files -> toolbox.log (for me in: ~/Library/Logs/JetBrains/Toolbox).
Change /usr/local/bin to another folder name of your choice with the correct access rights, e.g - I chose this name: ~/.jetbrains-launchers.
You can check if script is created by Jetbrains: ls ~/.jetbrains-launchers (you should see a script for each of the jetbrains applications you use).
Add this to your path if needed for example if you use zsh add this at the bottom of your .zshrc export PATH="$HOME/.jetbrains-launchers:$PATH"
Open a new terminal window and this should work.
Basically jetbrains will create script like this (in this case for webstorm cat ~/.jetbrains-launchers/webstorm):
#!/bin/bash
#Generated by JetBrains Toolbox 1.22.10970 at 2022-01-08T12:57:24.803251
declare -a ideargs=()
declare -- wait=""
for o in "$#"; do
if [[ "$o" = "--wait" || "$o" = "-w" ]]; then
wait="-W"
o="--wait"
fi
if [[ "$o" =~ " " ]]; then
ideargs+=("\"$o\"")
else
ideargs+=("$o")
fi
done
open -na "/Users/[YOUR-USER]/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/213.6461.79/WebStorm.app/Contents/MacOS/webstorm" $wait --args "${ideargs[#]}"
I also downloaded WebStorm and wanted to use a similar shortcut to open files directly from the terminal.
I was surprised to find I already had a shortcut in my command line tools for webstorm:
subl is to Sublime as wstorm is to Webstorm.
Otherwise, as anstarovoyt has kindly pointed out, you can simply create your own shortcut via "Tools" > "Create Command Line Launcher"
Another way to do that:
open -a /Applications/WebStorm.app #Open last project
open -a /Applications/WebStorm.app Desktop #Open particular folder
open -a /Applications/WebStorm.app Desktop myscript.js #Open particular file
You can add alias to your config file:
#Edit your config:
vim ~/.bashrc
#add line:
alias ws='open -a /Applications/WebStorm.app'
#Read your config file:
source ~/.bashrc
Now you can use it:
ws . myscript.js
I know this is an older thread, but trying to achieve this using Windows was kind of a pain and I wasn't able to find anything specifically designed for my purposes. I created a Bash function that you can add as an alias (for Git Bash on Windows) that works similar to the command line functions in Visual Studio Code.
Here's the link to the Gist.
If you change the integrated terminal in WebStorm to Git Bash (instructions included in the Gist), you can perform the following actions:
Create a new file in the current working directory and open it in the editor:
wstorm foo.js
Create a new file in an existing relative path and open it in the editor:
wstorm foo/bar.js
This also works with subdirectories that don't exist:
wstorm this/path/doesnt/exist/file.js
If you're working in a Git Bash terminal (not in WebStorm) and want to open WebStorm up in the current directory, you can open it similar to Visual Studio Code:
wstorm .
Note: This needs to be done in a directory with a .idea folder.
As of 2019-03-09, WebStorm 2018.3.4 on Mac does not have Tools > "Create Command Line Launcher...". However, this works:
WebStorm Preferences > Keymap > Main Menu > Tools > Create Command-line Launcher...
Right-click "Create Command-line Launcher..." > Add Keyboard Shortcut
Assign a keyboard shortcut
Close Preferences
Type the keyboard shortcut to open "Create Launcher Script"
Click Ok to run the script
You can now launch WebStorm from the terminal with webstorm and can choose a directory to open
After setting up WebStorm to create the cli launcher you actually want to run
wstorm . &
to run the IntelliJ on the background otherwise IntelliJ closes if you happen to close the terminal you have launched the app from.
In WebStorm IDE, click DOUBLE CLICK ON SHIFT and type Create Command Line Launcher then click OK from luncher script promote .
cd project_folder_path using terminal and type webstorm ./ .
that is not for Windows OS
In Ubuntu terminal type:
/var/opt/webstorm6/WebStorm-129.664/bin/webstorm.sh
Note: please see your WebStorm build version, code mine is 129.664
In the terminal, while being in the given project folder:
webstorm .
I know that this is a pretty old thread, but I recently came across this problem on Windows (I'm using the JetBrains Toolbox).
With the following steps all new and existing applications that have been installed with the Toolbox will be added to your path!
Follow these steps to achieve this:
Because of permissions, we need to create a new directory in your user. I named it .path, so that I can also store any other application there in the future. So this will be C:\Users\<PC_USER>\.path\.
The the Toolbox click on the gear icon in the top right corner.
Then click on Enable Shell Scripts and/or Generate Shell Scripts.
In the input field that is located under the switch paste your path folder. (C:\Users\<PC_USER>\.path\)
Open your Edit the system environment variables program that can be found in Windows search or the control panel.
Click on the Environment Variables... button that is located in the right corner, a new window should pop up.
In the new window select the variable that says Path in the Variable column from the top list and then click on the edit button that is situated under the top list. Another new window should pop-up.
Click on new and paste your path there. (C:\Users\<PC_USER>\.path\)
Click on Ok in Edit environment variable > Environment Variables > System Properties.
Go to C:\Users\<PC_USER>\.path\ and all your toolbox installed applications should be there.
Restart your CLI and it should work.
The wstorm command didn't work in my Git bash, so I added the following function to my .bash_profile instead:
wstorm() {
/c/Program\ Files\ \(x86\)/JetBrains/WebStorm\ 2016.2.2/bin/WebStorm.exe $PWD/$1
}
A short solution relevant to the year 2021 for Linux users.
Just execute the comand:
sudo ln -s /<your path to Webstorm directory>/bin/webstorm.sh /usr/local/bin/webstorm
Since /usr/local/bin should be in the PATH environment variable by default, you should be able to run the webstorm command from anywhere in the shell.
More details Webstorm docs
I am running Windows 10 and whipped up a batch file (ws.bat) that implements this with optional command line argument for path to load).
:: place this batch file in your path and set to your WS EXE
:: ref: https://www.robvanderwoude.com/battech_defined.php
:: author: bob#bobchesley.net
#echo off
set target=%1
if defined target (goto passedarg) else (goto noarg)
:passedarg
echo Starting WebStorm with '%target%'
"C:\Program Files\JetBrains\WebStorm 2018.3.2\bin\webstorm.exe" %target%
goto:EOF
:noarg
echo Starting WebStorm with 'Current Dir'
"C:\Program Files\JetBrains\WebStorm 2018.3.2\bin\webstorm.exe" .
Pretty simple but it works.
webstorm . doesn't work on Windows. Try this for the current folder:
webstorm $pwd
$pwd is the current folder's path