In Shift+Up isn't recognized by Emacs in a terminal I explain how terminals translate most function keys into escape sequences, because the interface between applications and terminals transmits characters (or rather bytes), not keys. Only a few modifier+character combinations have their own character:
Ctrl plus a letter or one of @[\]^_ turns into ...
M-x shell is the standard interface to OS's shell. On linux, it calls bash (or whatever your default), on Windows, it calls cmd.exe. M-x shell is the most frequently used.
M-x eshell is a shell written in emacs lisp entirely. It has a syntax similar to bash, but is integrated with elisp well. e.g. you can eval elisp code right there. Eshell is especially ...
First, the more general issue: terminal emulators are often limited in the control and escape sequences they can send. So: it may be the case that the terminal swallows your special characters before they reach Emacs. As a general diagnostic, you can hit C-h l (or M-x view-lossage) to see if your key combinations make it into Emacs.
For more discussion of ...
You will be more comfortable in an X11 Emacs, which can receive keyboard input and display text without going through encoding and decoding for the terminal. The main reason to use a text mode editor is to run it inside screen or tmux on a remote machine, but thanks to Tramp, it's usually easier to edit the remote file in your local Emacs. That being said, ...
In term-mode, there are two input modes. In the default input mode -- char-mode -- all keypresses (except C-c) are sent to the terminal to do what it wishes with.
If you change the input mode to line-mode, then regular Emacs commands work. You can switch to line-mode with C-c C-j. You can switch back to char-mode with C-c C-k.
I think the first part of your question can be done with dirtrack-mode. First, you set your shell prompt to include the present working directory. Next, you set dirtrack-list to a regex that tells dirtrack-mode how to extract it. Example: I set PS1 in Bash to be this:
export PS1="[\h:\w] $ "
and in Emacs I set dirtrack-list and turn on dirtrack-mode:
Like most terminals, Emacs' term has a scrollback limit -- which will naturally mess with the consistency of linum's counting, as lines will be deleted from the beginning of the buffer.
The term-buffer-maximum-size variable controls this, and sure enough it has a default value of 2048.
So linum was telling you the truth: the terminal buffer was never more ...
There are a few answers here.
Quitting Emacs without C-x C-c
First, you can quit emacs by running the command that C-x C-c is bound to: M-x save-buffers-kill-terminal.
Alternatives to recursive Emacs
Emacs is able to edit files on remote servers, so you don't even need to ssh into the remote server, and you won't need an Emacs inside a term inside your ...
From the Emacs manual, node DEL Does Not Delete:
On a text terminal, if you find that <BACKSPACE> prompts for a Help
command, like Control-h, instead of deleting a character, it means
that key is actually sending the BS character. Emacs ought to be
treating <BS> as <DEL>, but it isn’t.
In all of those cases, the immediate ...
shell is the oldest of the two. It uses Emacs's comint-mode to run a subshell (e.g. bash). In this mode, you're using Emacs to edit a command line. The subprocess doesn't see any input until you press Enter. Emacs is acting like a dumb terminal. It does support color codes, but not things like moving the cursor around, so you can't run curses-based ...
maybe using ansi-term instead would be slightly less annoying, since it exposes a C-x prefix, allowing you to use, say, C-x o or C-x k without any special trick.
If that's not sufficient, you can use the following approach:
(defun expose-global-binding-in-term (binding)
(define-key term-raw-map binding
(lookup-key (current-global-map) binding)))
In term-mode, any regular C-x whatever keybinding becomes C-c whatever instead.
Courtesy of Josh Matthews
Now to define keybindings that will be active only in term mode, try this:
(define-key term-raw-map (kbd "M-J") 'other-window)
(define-key term-raw-map (kbd "M-k") 'kill-buffer)))
Another try that disowns the process so your terminal will survive even after emacs is killed.
(defun run-gnome-terminal-here ()
(shell-command (concat "konsole --workdir"
(file-name-directory (or load-file-name buffer-file-name))
" > /dev/null 2>&1 & disown") nil nil))
The info reader in Emacs can be accessed with C-h i. There you can jump directly into the some-node node with g (some-node) RET.
Alternatively, you can go to the some-node node by eval'ing (info "some-node").
Note that the info reader on the terminal picks man pages when info nodes cannot be found. There is no "glibc" info node, but just a man page. To ...
The Emacs manual says you can set the option frame-resize-pixelwise to non-nil to allow frame sizes by pixel. Normally the frame dimensions (not counting the menu bar, tool bar, etc) are integer multiples of frame-char-height in height and frame-char-width in width. The manual notes that you need to set this variable to non-nil in your init file so that it ...
In my .emacs I first define a function like so
(defun my-bash-on-windows-shell ()
(let ((explicit-shell-file-name "C:/Windows/System32/bash.exe"))
and I call at the bottom using:
Note that Emacs shell mode does not handle the default colored prompt very well, however changing my PS1 to:
in my ...
;; Subprocesses of Emacs do not have direct access to the terminal, so
;; unless told otherwise they should only assume a dumb terminal.
;; We are careful to do it late (after term-setup-hook), although the
;; new multi-tty code does not use $TERM any more there anyway.
(setenv "TERM" "dumb")
If Emacs didn't set TERM=dumb then every ...
There's a very underappreciated feature most libraries that handle fonts provide for us, automatic fallback to different fonts if the font one has specified does not have all glyphs necessary to display the requested text correctly.
urxvt however does intentionally not come with automatic font fallback, at least not if you're not using fonts with the xft: ...
The bi-directional text support introduced in Emacs 24 interacts badly with term.el when large numbers of spaces or tabs are inserted, and many applications clear the screen (often drawing a new background colour) by writing WIDTHxHEIGHT spaces (which, if the terminal’s dimensions are sufficiently large, may take several seconds).
The workaround is to ...
Looking at term.el it seems char mode is enabled right after running term-mode (and hence term-mode-hook) as such enabling term-line-mode in term-mode-hook would not work. The only option I can think of is advicing the function term and ansi-term, like so
(defun my-enable-term-line-mode (&rest ignored)
(advice-add 'ansi-term :after #...
TERM is an environment variable, you set it in your environment. This could be the environment of a particular shell that you've opened, by running export TERM=foo, or all of your shells by adding the same command to your .bashrc (or a similar file for your shell, if you don't use bash. but you probably do use bash).
terminfo and termcap are databases ...
I believe that the @ symbols in your terminfo example are part of the Texinfo markup, rather than part of the terminfo code. Your terminfo entry should look like:
# Use colon separators.
xterm-24bit|xterm with 24-bit direct color mode,
Gilles' answer stated: On OSX, you can configure iTerm2 by selecting an escape sequence for each key combination, one by one. I had a little trouble getting there, so here a detailed explanation in case you are like me, confused.
If, when running Emacs in a terminal (e.g., Mac's default Terminal.app), C-x C-; does not run comment-line, and you would like ...
In general, a terminal application like emacs -nw has only very limited information about what colors are available. The shell will have an environment variable called TERM which contains the name of the terminal you're using. The application can then use a library such as terminfo to pick the right escape sequences to use each feature of the terminal. This ...
There is a way! The problem with using term is that term doesn't understand some of the escape sequences Julia sends, which causes term to put a bunch of extra prompts on the screen that make it unusable.
This method should also work for more or less any REPL or terminal application you could want to run.
There is a ridiculously useful terminal application ...
Termcap and terminfo are both methods for an application running in a terminal to obtain information about the terminal — what it can do and how (e.g. its size, how to move the cursor around, etc.). Both consist of a database that associates terminal capability descriptions to terminal names, as well as a library of code to query the database.
The TERM ...
On a terminal, you can't change the shape of cursor.
From the Emacs manual:
On a text terminal, the cursor’s appearance is controlled by the
terminal, largely out of the control of Emacs. Some terminals offer
two different cursors: a “visible” static cursor, and a “very visible”
blinking cursor. By default, Emacs uses the very visible cursor, and
If you're in term buffer in char mode, you have to escape C-c. So, if you're running a terminal Emacs instance inside the term buffer, running save-buffers-kill-terminal requires an extra C-c: C-x C-c C-c.
If you're running an Emacs instance in a term buffer in line mode, I don't think there's a direct way to kill the nested Emacs. You have to switch back ...
You can add:
For C-M-left: Send escape sequence: [1;7D
For C-M-right: Send escape sequence: [1;7C
For C-M-up: Send escape sequence: [1;7A
For C-M-down: Send escape sequence: [1;7B
And this will work with Emacs if you set the term in iTerm2 to be reported as xterm.
To know how to figure all this out, well its complicated, and I just went down this rabbit ...