When I am running Emacs from a terminal, how do I find out the tty device name from inside Emacs?

I first thought that it can be done with M-x shell-command RET tty RET, but this does not work: instead of, e.g., /dev/tty1, I get not a tty.

  • I found the (terminal-name) ; => "Mac function by searching for terminal with C-h f, I'm not sure if it is related, I don't know what's the meaning of "tty" and "terminal". M-x shell-command, M-x shell and M-x ansi-term don't use the same "terminal" as emacs itself, so running the tty command inside emacs won't work. When I run emacs from a terminal emulator , (terminal-name) ; => "/dev/tty", but the tty command outputs /dev/ttys000. – xuchunyang Jul 12 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.