11

When I run emacs in a terminal (using the -nw option) my theme is broken and some key-bindings don't work.

So, I need to disable the theme and some keybindings when running in a tty.

Is there a way to do that?

Constantine
  • 9,122
  • 1
  • 35
  • 50
Nishant
  • 113
  • 1
  • 6

1 Answers1

22

You can use display-graphic-p to determine if you are running in a terminal or a windowing system.

For example, you could do your setup so that you only add those keybindings and theme if you know you're on a window system.

(when (display-graphic-p) 
    ;; Do any keybindings and theme setup here
  )

You can also do the reverse, and turn off your keybindings and theme.

(unless (display-graphic-p) 
    ;; Remove any keybindings and theme setup here
  )
Infiltrator
  • 223
  • 1
  • 4
Alan Shutko
  • 847
  • 7
  • 6
  • Matches the suggestion at the bottom of https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Systems.html – Joshua Goldberg Nov 27 '20 at 15:57
  • Do not use window-system and initial-window-system as predicates or boolean flag variables, if you want to write code that works differently on text terminals and graphic displays. That is because window-system is not a good indicator of Emacs capabilities on a given display type. Instead, use display-graphic-p or any of the other display-*-p predicates described in Display Feature Testing. from https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Systems.html – Ford Guo Feb 20 '24 at 01:43