In the GUI version of Emacs, it is easy to see that something like (blink-cursor-mode t) makes the cursor blink.

However, in a terminal emulator, such as on Mac OS X, it is possible to set things such as the cursor color or whether or not the cursor blinks, in various places (like your ~/.profile or in the Terminal Preferences.

So, my question is, what determines when a "graphical" element, such as text color, is controlled by a terminal emulator (in Terminal in Mac OS you can set the ANSI colors) versus when Emacs controls it (specifically when Emacs is running in a terminal emulator)

  • ~/.profile controls the shell that the terminal emulator is running (like bash). AFAIK it has no control over the appearance of a particular terminal emulator
    – nitishch
    Commented Jul 22, 2016 at 8:21

1 Answer 1


The terminal application has full control over the graphical elements. The gui terminal app will give text applications some control via “escape codes”. For example, vt100/xterm terminals, including Mac OS X Terminal, allow you to change colors using the sequence ESC [ numbers m. Try it in the shell:

echo -e "\e[1;37;41mhello"

This should print the word “hello” in a white foreground on red background.

Emacs uses these codes to control the text color. Note: although most terminals use the same sequences for colors, other codes are not always the same, so applications normally go through some library (termcap? curses?) and the TERM environment variable to look up what's needed and available in the given terminal. Emacs has its own elisp for each terminal type; see the source file term/xterm.el for example, or term/README for more details.

Cursor style is available in some terminals but not all. iTerm2 has its own set of sequences; I don't know if there's a similar list for Mac OS Terminal. They both emulate xterm/vt100 which has a long list here. The “set cursor style” sequences on that page show control over blink/underline/solid, but I don't think Terminal or iTerm2 support those. I've not seen any codes for cursor color; Emacs on my system is unable to set the cursor color in either Terminal or iTerm2. You can fake blinking by hiding the cursor (ESC ? 2 5 l) and then showing it again (ESC ? 2 5 h) at some interval.

Related: an emacs frequently asked question is why you can't bind some keys in the terminal version of emacs, and the answer is that it's up to the terminal to decide which keys are sent to the program, and not all keys are assigned an escape code, so emacs can't see them all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.