Hot answers tagged

45

IPython 5 has a new terminal interface, which is not compatible with Emacs' inferior shells. To fix it, add the --simple-prompt flag to the IPython command: (setq python-shell-interpreter "ipython" python-shell-interpreter-args "--simple-prompt -i") From the documentation: The new interface is not compatible with Emacs ‘inferior-shell’ feature. To ...


32

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 ...


21

You can start background processes with start-process, which shouldn't pop up a buffer: (start-process "process-name" "buffer-name" "program") Process names are modified to avoid duplication as necessary, so don't worry about that. Just give it a name useful for debugging in the future! If you give a "buffer-name", a buffer will be created but not shown ...


20

You can also install exec-path-from-shell package and add this to your init file: (exec-path-from-shell-initialize)


16

comint-derived modes (like shell, ielm, ...) support filter functions, the following snippet makes the output and prompt read-only: (setq comint-prompt-read-only t) (defun my-comint-preoutput-turn-buffer-read-only (text) (propertize text 'read-only t)) (add-hook 'comint-preoutput-filter-functions 'my-comint-preoutput-turn-buffer-read-only) As for ansi-...


16

I think you're looking for comint-prompt-read-only. E.g. (setq comint-prompt-read-only t) should take care of it.


15

Turns out it was projectile that was causing the problems. As soon as I disabled projectile-mode TRAMP was buttery smooth and I began to understand the hype behind it. Hopefully this helps out someone else who has exhausted all other options. Another solution I found if you don't want to disable projectile constantly is to put this command in your init.el ...


14

You can clean up the *Messages* buffer the same way you always could, with the kill-buffer command. The next time a message is signaled, the buffer will be recreated anew. The reason that this buffer is read-only now, is that it has been granted its own major-mode, which inherits from special-mode, which is read-only. The advantages behind that are several. ...


14

This is the correct behaviour. .bash_profile is for so-called login shells. Like when you log in to your computer in text mode, or in a terminal emulator to a different computer via ssh or telnet or ... .bashrc is meant for non-login shells, like when you are already logged in and start a new xterm, or in this case emacs' shell mode. Usually the ....


13

In Shell mode, Emacs detects password prompts based on the prompt. If it sees Password: (or Enter new password:, or Passwort:, or Wachtwoord: or a number of variations), it assumes that you're prompted to enter a password and reads a string from the minibuffer (repeating the prompt); this string is not echoed and is not entered in any history list. If Emacs ...


11

Since mention that the command is running asynchronously I am assuming you mean the command async-shell-command bound to M-&. You can follow the advice in documentation of async-shell-command (you can read it by doing C-hfasync-shell-commandRET) customize display-buffer-alist as follows (add-to-list 'display-buffer-alist (cons "\\*Async Shell Command\\*....


11

The ^[] noise is coming from various terminal control characters in your shell prompt. Try echo $PS1 to see the full sequence, and try e.g. export PS1='$ ' to see that a simpler prompt string removes that particular problem. For the encoding, you might try making utf-8 your preferred encoding: (prefer-coding-system 'utf-8) Setting up the prompt Emacs ...


11

In addition to the points made by @pingi, you can also use a separate configuration file that will be loaded only for the emacs shell (M-x shell): From the manual page (emacs) Interactive Shell: Emacs sends the new shell the contents of the file ‘~/.emacs_SHELLNAME’ as input, if it exists, where SHELLNAME is the name of the file that the shell was ...


10

Go to the buffer you want to rename, in your case *shell*. Then type M-x rename-buffer and enter the new name for this buffer.


9

The "problem" is that with M-x shell (or M-x eshell btw), Emacs uses a very limited terminal emulator, so that TERM is correctly set to dumb Fancy pagers cannot operate under such limited constraints, which is why you have to use cat instead. Now, when you open an ssh connection from that shell, TERM is still dumb, but PAGER is reset to whatever the other ...


9

This is an OSX annoying environment issue, the $PATH appearing in Emacs is coming from /etc/paths file, which then gets appended with whatever I've set in the shell. I added /Users/g/Library/Haskell/bin to the top of the /etc/paths file and it then worked fine. Going into shell and calling echo $PATH in Emacs shows now: /Users/g/Library/Haskell/bin:/usr/...


9

Well, as @dshepherd mentioned, you are missing /usr/local/bin in PATH. git is working probably only because there is symlink in /bin. Try export PATH=$PATH:/usr/local/bin in emacs terminal. You can also check this out: https://stackoverflow.com/questions/8606954/path-and-exec-path-set-but-emacs-does-not-find-executable In the future, in case of similar ...


8

Like Tikhon mentioned, (start-process) is the way to go. In case you don't want to create a buffer but would still like to react to the background process status, you can also employ (set-process-sentinel). Here's a modified example I'm taking from my projector package: (set-process-sentinel (start-process "process-name" nil "command") #'output-message-...


8

The canonical way of altering the display behaviour for a buffer is to customize display-buffer-alist: (setq display-buffer-alist '(("\\`\\*e?shell" display-buffer-pop-up-window))) (setq display-buffer-alist '(("\\`\\*e?shell" display-buffer-pop-up-frame))) It's a bit easier with my shackle package though: (setq shackle-rules '(("\\`\\*e?shell" :regexp t :...


8

save-window-excursion is a macro for running a piece of code without altering the window configuration. Something like this should work: (defun my-view-pdf () (interactive) (save-window-excursion (async-shell-command (concat "SumatraPDF " (file-name-base (buffer-file-name)) ".pdf"))))


8

If you just would like to spawn a process in the background you don't need all the bells an whistles that shell command functions provide. Instead, you can use the function call-process. For example: (call-process "a_command" nil 0 ; <- Discard and don't wait nil "arg1" "arg2") Concretely, this mean that you can ...


8

In spite of what I wrote in the comments one can set cmd as shell in ob-sh! The only thing to be aware of is that one needs to use cmdproxy.exe instead of cmd.exe to get the output to stdout right. You can also do this on a per-code-block basis with the following small advice (working with your version GNU Emacs 25.0.50.1 (x86_64-w64-mingw32)). It defines ...


8

The control sequences ^[[?2004h and ^[[?2004l turn bracketed paste mode on and off. Shell mode doesn't support bracketed paste mode (with these or any other control sequences), so zsh shouldn't try to turn it on. Shell mode correctly advertises that it doesn't support these control sequences by declaring TERM=dumb. It seems that zsh blindly assumes that the ...


8

Interactively, C-u M-! (i.e., shell-command with the universal argument prefix) will prompt you for a shell command and insert the output in the current buffer. To do this from elisp code, see the comment from @lawlist org-mode also has fairly sophisticated methods of its own for evaluating code, including both inline code and code blocks. First, you need ...


8

You need to change the option shell-file-name. (setenv "SHELL" "/bin/bash") This doesn't work since Emacs is already running thus it's too late, Emacs initializes shell-file-name according to SHELL during startup. Something like $ SHELL=/bin/bash emacs should work. (setq explicit-shell-file-name "/bin/bash") This is for M-x shell, not M-x shell-...


7

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 ...


7

Use display-buffer-alist with the display-buffer-no-window if you're on Emacs 24.4 or later. (setq display-buffer-alist '(("\\`\\*Async Shell Command\\*\\'" display-buffer-no-window))) Alternatively, use shackle: (setq shackle-rules '(("*Async Shell Command*" :ignore t)))


7

As Gilles mentioned in the comment above, emacs does not read the local env settings unless specifically asked to. The easiest way to keep variables in shell terminals inside and outside Emacs is to use a package, such as the Steve Purcell's package exec-path-from-shell. Once installed, this package ensures each time you start a shell in emacs, it reads ...


7

Did you successfully fix the problem? Sure! ob-shell was flipping out and you stopped loading it. That is, in some sense, a fix! That said: the chunk of code you found and commented out controls which languages are loaded by org babel, which is a pretty powerful function within org. If you've got any interest in using/evaluating shell code blocks, you'll ...


7

This is an ancient version of emacs that came preinstalled with macOS. To find out where the version of emacs that you installed is, start it by clicking on the icon and then evaluate (expand-file-name invocation-name invocation-directory). Then post that into a shell.


Only top voted, non community-wiki answers of a minimum length are eligible