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 ...
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 ...
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)))
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 ...
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 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 ...
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 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 ...
(defun my-applescript-fn ()
"Open the Terminal.app, wait a second, and CD to the Emacs default-directory
of current buffer."
"tell application \"Terminal\"
do script with command \"cd %s\" in window 1
end tell" default-directory)))
I use ansi-term almost exclusively, so I would say "almost".
Speed is your main concern -- anything which rapidly generates large amounts of output is going to cause some pain, as Emacs won't keep up with it. If I know I'm about to issue such a shell command, I pull up a dedicated terminal emulator.
If you're using Emacs 24 then https://www.emacswiki.org/...
This is a simplified version of a function in my .emacs file:
(defun ml/bash ()
"Start a terminal emulator in a new window."
(ansi-term (executable-find "bash")))
You can bind it to C-c a:
(global-set-key (kbd "C-c a") #'ml/bash)
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 ...
Technical explanation: that's because emacs-startup-hook is run after the init file is processed, therefore your call to multi-term is run after you do the rename operation.
Now, you don't need emacs-startup-hook at all, what you really want is to run those things in sequence, right from your init file. And you don't need to call get-buffer (which needs a ...
Given the pointer to term-handle-ansi-escape by @jch I was able to add support for CHA as follows:
(defun toolbear:term-handle-more-ansi-escapes (proc char)
"Handle additional ansi escapes."
;; \E[nG - Cursor Horizontal Absolute, e.g. move cursor to column n
((eq char ?G)
(let ((col (min term-width (max 0 term-terminal-parameter))))
Since in zenburn theme terminal colors look good I added the following lines in my .emacs:
'(term-color-black ((t (:foreground "#3F3F3F" :background "#2B2B2B"))))
'(term-color-red ((t (:foreground "#AC7373" :background "#8C5353"))))
'(term-color-green ((t (:foreground "#7F9F7F" :background "#9FC59F"))))
'(term-color-yellow ((t (:...
This is a helpful overview of ways to use the various shells and terminals in emacs. I use eshell for most things (here's my config for eshell) if you care to take a look. But as the other answer notes, if you're going to be dumping a lot of text in a terminal, emacs will likely be too slow.
This should now be fixed in the master branch. As mentioned in the comments, bugs should be reported to the bug tracker. If you are not sure if something is a bug, testing with emacs -Q is a good indicator (and you should do that anyway, before reporting).
4c33ad4a24: Fix line-wrapping for term.el (Bug#30775)