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?

1 Answer 1

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
  )
2
  • Matches the suggestion at the bottom of gnu.org/software/emacs/manual/html_node/elisp/… Nov 27, 2020 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 gnu.org/software/emacs/manual/html_node/elisp/…
    – Ford Guo
    Feb 20 at 1:43

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.