How to run emacs in CLI mode under mintty in windows?
Asked Answered
O

2

16

I'm using mintty + msys. And I want to use emacs with it. But without GUI.
I saw such behavior in cygwin. But I can not understand how they did that.

$ emacs -nw
  emacs: standard input is not a tty

$ stty.exe -a
  speed 38400 baud; rows 24; columns 80; line = 0;
  intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
  eol2 = <undef>; swtch = ^Z; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
  werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
  -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
  -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
  -iuclc ixany imaxbel
  opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
  isig icanon iexten echo echoe echok -echonl -noflsh -tostop echoctl echoke

$ echo $TERM
  xterm
Obtain answered 22/1, 2013 at 18:16 Comment(2)
what is the TERM set to? what does 'stty -a' say?Theis
hmz works for me, in xterm and even in mintty. thanks for params btw, cause i couldn't find how to get emacs cli on xterm :)Persse
C
9

If you want to use tty emacs with mintty, you will probably need to use cygwin's emacs. The native win32 emacs wants to talk to a Windows console window, not to an actual tty -- the error message is misleading here.

Another alternative, if you want to stick with the native win32 emacs, is to use ConEmu, rather than mintty. It gives a compatible Windows console interface while also providing all the niceties of a normal terminal emulator like mintty.

Cristalcristate answered 25/3, 2015 at 13:22 Comment(2)
The more recent Windows Terminal, which comes bundled with Windows, would also be a good choice. A lot of people are confused about tty-based vs. Windows console-based terminals, in which case some may find this discussion on MSYS2's website helpful.Osteo
This quote in particular looks useful if for some reason you still need to use a tty-based terminal with Windows console-based emacs and don't want to install cygwin: Winpty is a wrapper program that works as a translator between Windows programs and MSYS2 terminals. It opens an invisible Windows console window and runs the wrapped program in it. It then relays input from the terminal to the program and output from the program to the terminal. This solves a lot of the issues of running Windows programs in a MSYS2 terminal.Osteo
X
9

You should use winpty:

winpty emacs -nw

winpty is a Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programs. The package consists of a library (libwinpty) and a tool for Cygwin and MSYS for running Windows console programs in a Cygwin/MSYS pty.

Emacs in your case is actually "Windows console program".

Xylotomy answered 23/7, 2016 at 17:9 Comment(2)
This 60-year-old CLI user thanks you. Windows 10 Msys2 (msys2-x86_64-20161025) the msys emacs (local/mingw-w64-x86_64-emacs 25.2-1) C-C is mis-translated into "<pause>" (see: superuser.com/questions/93771/c-x-c-c-not-working-in-emacs-23-1). Using Cygwin emacs binary (emacs-nox 25.1.1) seems to work OK.Extraditable
A relatively simple workaround for the Ctrl-C issue is to add mappings containing pause for any shortcuts containing C-C that one wishes to use. E.g. for C-X C-C: (global-set-key [24 pause] (quote save-buffers-kill-terminal)) See also: superuser.com/a/1361203/381671Oppress

© 2022 - 2024 — McMap. All rights reserved.