Emacs on Windows disable cmd - emacs

I've always used Emacs under Linux, but now I got a Windows machine and installed it.
However, every time I open Emacs it also opens a terminal (called cmd.exe on Windows, I think). Is there a way I can disable that terminal?
Thank you.

If you got the GNU version of emacs for Windows from here: http://ftp.gnu.org/gnu/emacs/windows/, there is an .exe called runemacs.exe. Use that instead of emacs.exe. "runemacs" will not pop up the annoying cmd window.

Related

How to get Emacs on MINGW64 (Windows 10)

I currently use MINGW64 (Git Bash) as my terminal on my Windows 10 machine. It works great, I like it, but it only has Vim installed as an editor and I prefer Emacs. I'm unfortunately having a really awful time getting it to work in my terminal.
What's weirder still is that I have Emacs working in Cygwin64; but I don't like using that as my terminal. The most logical fix is simply that it Emacs to my Path ENV, however that doesn't seem to help (perhaps I'm doing that wrong?). I just get bash: emacs: command not found. I found a command to install it, using Pacman, however the Pacman command cannot be found either (which is weird because I thought that was installed by default with MINGW64.
Would love any and all help on this.
A couple of options:
Use Cygwin and the Cygwin emacs. Consider your Cygwin environment completely separate from Windows, so set your PATH from within the .bashrc, not within Windows. Launch emacs from the bash command-line.
Use the Emacs Windows binary distribution, but point to the utilities within Cygwin (there's an emacs package to help with this). Again, launch from the bash command line to inherit the bash environment within emacs.
Use the Windows Subsystem for Linux, with a Linux installation, and stick with emacs from there. You get the best of the Linux world, and access to the Windows directories and files as well.
My goto choice for MANY years was the Emacs Windows binary in conjunction with Cygwin. Once I started using the WSL, however, it just worked a lot better, in a clean Linux environment, and I could get terminal and GUI emacs (and other apps) running using the VcXsrv X Server. WSL has a version that directly supports X Windows, but I don't care for the windowing environment it uses, so I stick with VcXsrv.

Selecting Python interpreter from WSL

I am using Windows 10 and want to set the the default VSCode interpreter for Python to be the same one used in my WSL 2 (Ubuntu), so that I'm always using "one Python".
When I click "Select Python interpreter" a prompt appears to find the interpreter path, but I'm not sure what the path would be.
I think that, in order to use the WSL python, you need to be running VSCode in a WSL remote window. You need to install the Remote WSL extension first. Then, on the lower left there is a green button that will let you start a WSL window, or it will tell you that you are already in one.
If you are in a WSL window, you should be able to select your python interpreter pretty easily. It will either automatically detect it, or you can run which python3 in an Ubuntu terminal to get the path. If you want to navigate to a file on your Windows file system from within this window, look in, e.g., /mnt/c/Users/<USER_NAME>.
Well probably late to the party but you can find Python you are using on your WSL2 with simple command:
which python3
It will show you where is the python placed.
While above answers work, there are some related things to keep in mind here (or are at least worth mentioning):
I would recommend to create a virtual environment for your project. If you do so, its very easy to find the python interpreter in the bin folder of the venv. (If you want to "find" your WSL folder in windows. Just enter explorer.exe . in your terminal - it will open a windows explorer in the current location.
If you open the python interpreter selector form within VS Code on Windows, be aware that it opens a windows that let's you select "Executables" (meaning WINDOWS wxecutables):
You will not be able to open your python interpreter located in your wsl like that, as the folder will be shown as empty.

Integrated Terminal Setting VS Code and iTerm returns zsh

I'm trying to use iterm as my focus terminal inside vscode. I've setup "terminal.external.osxExec": "iTerm.app", but I get zsh instead of iTerm.
I'm able to right click on a file and open in iterm but I love the integrated terminal, and want to use iTerm here.
How do I use iterm as my terminal?
You cannot set iTerm as the integrated terminal for VS Code. I have explained below why.
iTerm is not a shell but a terminal emulator which in your case is running the zsh shell.
I believe you are confusing the terms Shell and a terminal emulator.
iTerm is a terminal emulator. Some examples of terminal emulator are Gnome terminal, Guake, Xterm etc. They provide a display to the shell which is installed in the OS.
A shell is a command line interface that reads and interprets your commands. Examples of shell are bash which comes by default in Linux and other shells like zsh, fish, sh.
Visual Studio Code integrated terminals use the shell itself and not the terminal emulator. In Windows OS the distinction between shell and terminal emulator is not present so Powershell and Command Prompt are both the shell and the emulator.
But for Unix like OSes there is a distinction.
I believe you use iTerm as the terminal emulator and the shell used is zsh (pronounced Z Shell which is a fork of bash Bourne Again Shell).
Here is a wikipedia article on Unix Shell. This talks about what a Unix shell really is.
This link is about Terminal emulators which also talks about the history of terminals.
This link gives a list of terminal emulators
that are available. iTerm is a terminal emulator for Mac OS.
Though you can customize your normal terminal using this
then later remember to go to settings then assign the new configurations to override the default ones
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "Meslo LG S DZ for Powerline",
"terminal.explorerKind": "external",
The accepted answer has precisely addressed the question.
Here I will add a side note:
Why do you want iterm2 in integrated shell?
My answer is: I want the "copy on selection" feature of iterm2.
Actually vscode has this setting for the integrated terminal!
Settings > Terminal > Integrated: Copy On Selection
By the way, vscode also allows you to split the terminal, which is like iterm2.

How to disable emacs console messages

When I open emacs from a terminal with the emacs& command, I get a lot of debug messages on that terminal. This obscures what I was doing before. Is there a way of suppressing debug message output to the terminal?
Thanks!
Redirect stderr to /dev/null.
emacs 2>/dev/null& command
This alias should to the trick, just put in in .bashrc or your shells rc file.
alias emacs="emacs 2>/dev/null"
It depends on your OS, but you seem to be on Linux.
If it is the case, create a launcher icon, eg for Ubuntu.
This way the desktop environment, like Gnome or KDE, starts the process instead of the terminal, and messages do not appear.

How Can I Get MinTTY (Cygwin Terminal) to Open Emacs in a New Window?

I can't figure out why this isn't easy to find on Google, but after searching for about 10 minutes, I just decided to give up and post here.
The subject basically says it all. I'm running MinTTY as a cygwin terminal on a Windows XP desktop. All I want to do is have emacs open up in a new window rather than inside my terminal. What would be best is a switch for this, so I could toggle it depending on my current needs. This seems like something that would be useful to a lot of people, and I know I've done it before on Linux boxes, so I imagine there must be a way to do this in cygwin too. Anyone know how?
Just start a new mintty, telling it to invoke emacs:
mintty emacs
There are a couple of scenarios that you might clarify:
Running the cygwin version of emacs within a standard windows environment will call emacs within the current shell
If the Cygwin X-Windows server (i.e., “XWin Server”) has been started and the DISPLAY environment variable has been set in the mintty terminal (e.g., export DISPLAY=":0"), calling emacs will start it in its own window.
running the Windows version of emacs within the cygwin terminal should launch the new frame you are seeking.
If you want a separate emacs 'window', you would be best served by installing the Windows native version of emacs (I use the gnu emacs precompiled binaries), and calling it from the cygwin terminal.