JetBrains IDE on Windows: Execute run config with Git Bash - jetbrains-ide

How can I configure my JetBrains IDE (PhpStorm in my case) on Windows to execute run configurations with Git Bash instead of using the default Windows shell?
I've configured the terminal tool window to use Git Bash via Settings > Tools > Terminal, but there doesn't seem to be a way to force the Run window to use the same shell. So I can successfully run some commands that depend on tools like grep from the Terminal tool window but not via my run configurations.
To be clear, by run configurations I mean these:

You can set npm in general to use bash:
npm config set script-shell "$HOME\AppData\Local\Programs\Git\bin\sh.exe"

If you set the following VM option, it should work.
-Dspring.output.ansi.enabled=ALWAYS
Ref. Colorize console output in Intellij products

Related

nvim started as desktop application | :checkhealth - commands not available

When I start neovide from my applications and run :checkhealth I get errors that node and other commands are not available. But when I start it from my terminal there is no error for those commands. I tried to copy and modify the neovide desktop file to start just nvim and see if there if something wrong with my my neovide installation. But also starting just nvim as application prints the same errors.
I'm using linux with plasma desktop
TL:DR; add a path variable
Depending on your configuration, nvim will need to know the environment to run some executables (like it is with node in your example). An easy solution is to add the path variable to the exec command in the according .desktop file. I remember that I had the same issue with node not being recognized in a configuration using my plasma installation. On gnome node was recognized and healthchecks were good, so I thought I didn't need the extra path. Later on I realized that I had trouble with other commands. E.g. when using fdfind to complete path commands. Again I had to search what the reason was and it also was the missing path.
To give an example, let's say you are using zsh and want to start neovide with multigrid enabled, the Exec line in your desktop file could look like:
Exec=zsh -c "source ~/.config/zsh/.zshrc && neovide --multigrid %F"

WSL-2 `code` command installs vscode instead of using local windows install

I have a local vscode installed for windows.
Afterwards I setup wsl-2 and use it as my shell.
When I tried to open a file with code using the code filename command, it installed vscode anew instead of using the local windows install.
Installing VS Code Server for x64 (054a9295330880ed74ceaedda236253b4f39a335)
Is there a way to point wsl to use the windows install when triggering it via the code command?
I don't specifically mind using either or, but settings/extensions etc. for one are not used by the other.
By checking with Git Bash where the location of code is when triggering it (type -a code) and comparing it to the ubuntu wsl shell, I came to the conclusion, that it is actually the same install that is being triggered, . I will have to check why some extensions do not seem to "carry over" though.
The code that is being triggered is a script, that behaves differently when being triggered from within WSL.
How about an alias?
# Set alias
alias code2='/mnt/c/Users/Username/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code'
# Open a file now
code2 file.txt

How can I launch gitahed from terminal?

I enjoy using gitahed, and I would like to add a shortcut to lauch it, with github desktop I use github-desktop, but I can do the same with GA?
How can I launch gitahed from terminal?
GitAhead has a Terminal panel at Tools->Options. It has a button to install command line tools. It really just creates a symlink to the GitAhead binary in /usr/local/bin. If that doesn't work for some reason, you can create the symlink yourself or an alias. See command line options by running with the --help flag. There are only a few at the moment.

How to change WebStorm enviroment settings for File Watcher?

I have simple File Watcher that run TSLint. If I copy the command and run it in the console all fine but WebStorm run it with old Node version and throw error Buffer.alloc is not a function.
I'm using nvm to manage node.js versions.
ubuntu 16.4
Different Node.js versions are on your $PATH when you start your script from the IDE and from terminal.
When being launched from desktop/System menu, WebStorm only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
Workaround 2: run IDE from a terminal, either with the command line launcher or with bin/webstorm.sh
Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/webstorm.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)
see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

How to activate python virtual environment in VS code terminal?

I have created a python virtual environment using VS code editor.
a virtual environment is created successfully but I am not able to activate it.
when I am trying to activate my virtual env
I have also tried with "activate.bat"
I was trying to activate virtual env command in PowerShell which is by default selected in VS Code, that why it was giving me an error.
we can select different terminal(PowerShell, Command Prompt, Git bash) in VS code. so I have just selected cmd(Command Prompt) and now it is working.
You are using Powershell in your terminal (as denoted by PS) in the begining of every line in the terminal. You can switch to cmd and it will work. To do this, check the above asnwer by Sandeep Bhatt. If the option is not available, follow these steps,
Open commands search (use Ctrl+Shift+P or from menu View->Command Palette...) while terminal is open
In command box that appears, type "Terminal: Select Default Shell" and select it.
All the available commands which are in path will be listed. Select command prompt here.
Once this is done, you can change into cmd by clicking the plus icon shown here
You need to change the shell like here in the picture
change it to git bash or terminal of windows, and use the command "source FolderNameOfVirtualenviremenrts/Scripts/activate" (this command is for git-bash terminal)
Assuming that you're using powershell and your python virtual environment is in the 'venv' folder then you'll need to source the Activate.ps1 script by using the following command
. .\venv\Scripts\activate.ps1
The dot (.) is the equivalent of "source" command in powershell.
After sourcing Activate.ps1 the virtual environment commands activate and deactivate will work.
With newer versions of virtual environments (https://github.com/microsoft/vscode-python/issues/6931) you can also activate the environment as in the following example:
& .\venv\Scripts\Activate.ps1
This should work now if you are in powershell:
.\Venv/Scripts/Activate.ps1
It's unclear what you're using to create the virtual environment, and I presume that you're simply accessing the terminal from VSCode.
Try source activate <env_name> to start your environment.

Resources