Hot answers tagged

41

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


31

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


15

The function that cycles backwards through input history, saving input. is comint-previous-input It is bound to C-up, M-p.


14

First of all check which sudo is executed in your eshell session. It can be your system’s sudo: $ which sudo /path/to/system/wide/sudo $ which *sudo /path/to/system/wide/sudo or eshell’s sudo: $ which sudo sudo is a compiled Lisp function in `em-tramp.el' $ which eshell/sudo eshell/sudo is a compiled Lisp function in `em-tramp.el' Eshell’s sudo uses ...


11

That looks like a bug in eshell, you should report it. I think you can fix it by (defadvice eshell-gather-process-output (before absolute-cmd (command args) act) (setq command (file-truename command))) Bottom-line, the problem is that tramp ends up constructing a remote command line of the form (I'm removing some escaping to make it clearer): cd /home/...


11

My initial hunch was looking for an official command that does this already, so I've found eshell-command. However that outputs to a separate buffer, so it's not an option. Here's an example with ls and an *eshell* buffer: (with-current-buffer "*eshell*" (eshell-return-to-prompt) (insert "ls") (eshell-send-input))


10

The alias command of eshell can also be used to remove aliases: just leave out the definition part. $ alias hello


10

This should work fine: (define-key eshell-mode-map (kbd "<tab>") 'completion-at-point) I don't know why the above isn't the default. But I use only shell-mode and term-mode anyway.


8

There is a function in the current development version, as you can see on the emacs-devel mailing list. The function is very simple: (defun eshell/clear () "Clear the eshell buffer." (let ((inhibit-read-only t)) (erase-buffer) (eshell-send-input))) Typing clear in eshell will then result in clearing the buffer.


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

(defun eshell/my-find-file (pattern) (mapc #'find-file (mapcar #'expand-file-name pattern))) then use my-find-file **/Threshold.java from Eshell, if you also want my-find-file to support non-glob pattern (for example, my-find-file Threshold.java), try following: (defun eshell/my-find-file (pattern) (if (stringp pattern) (find-file pattern) (...


7

The Emacs equivalent of the PATH environment variable is exec-path, which is a list instead of a colon-separated string. Its content it initialized with the value of PATH, so supposedly it should be all transparent. But if this happens not to contain what you want (typically when Emacs is not run from a shell, but from a Desktop Environment), you might ...


7

I hate to break this to you, but it's the built-in default behavior. :) Welcome to the Emacs shell ~/.emacs.d $ / / $


6

If it's just for a single invocation then, as per the eshell manual (look for the "Built-in commands" section), you can prefix any command with '*' to ignore the built-ins: $ which ls eshell/ls is a compiled Lisp function in `em-ls.el' Compared with: $ which *ls /usr/bin/ls That same page has the tip that if you wanted to always do this (say for your rm ...


6

Based on what happens behind the scenes when you call iimage-mode, you can define a function that takes care of displaying images for you, and have Emacs run this function every time you issue an echo command in Eshell: (defun iimage-mode-refresh (command args) (when (string= command "echo") (let ((image-path (cons default-directory iimage-mode-image-...


6

You'll need to redefine the alias for eshell. For instance if you alias nth to echo hi in bash then in eshell type alias nth echo hi eshell will write your aliases to your eshell-alias-file where they will persist.


6

As far as I know there is no built-in support for brace expansion. You can, however, use plain elisp: ls -la (mapcar (lambda (x) (concat "prefix-" x ".suffix")) '("A" "B" "C")) This will run ls -la on the list ("prefix-A.suffix" "prefix-B.suffix" "prefix-C.suffix"). Here's another solution. Define this function: (defun eshell-brace-expansion (str) (...


6

Taking the suggestion from PythonNut and rekado, I have switched to truncating when idle, so my current solution looks like: (defun my/truncate-eshell-buffers () "Truncates all eshell buffers" (interactive) (save-current-buffer (dolist (buffer (buffer-list t)) (set-buffer buffer) (when (eq major-mode 'eshell-mode) (eshell-...


6

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


6

Add the follows to your init file and use M-x man or the man command in eshell to view man pages: (the colors fits the wombat theme; you can change them for yourself) (require 'man) (set-face-attribute 'Man-overstrike nil :inherit 'bold :foreground "orange red") (set-face-attribute 'Man-underline nil :inherit 'underline :foreground "forest green") Or to be ...


6

When it gives an error code, then the command will be passed to the real shell No, eshell is the "real shell". If there no such internal command, then eshell will look for an external command of the same name (this is what all shells do). type is not an external command, it's an internal command of some other shells (try running type type in your terminal ...


6

I found something that seems to work OK upon initial testing: essentially rebind <tab> to pcomplete-std-complete, but since that function isn't interactive for some reason, you need to wrap it: (define-key eshell-mode-map (kbd "<tab>") (lambda () (interactive) (pcomplete-std-complete))) The pcompete-std-complete tries to use the completions ...


5

You can configure TRAMP to respect the PATH variable on the remote machine (for remote eshell sessions) by adding 'tramp-own-remote-path to the list 'tramp-remote-path: (add-to-list 'tramp-remote-path 'tramp-own-remote-path) By default, eshell will not adopt the remote PATH settings.


5

This question has been already answered by rekado (thanks!) (as a reply to another more general question about eshell): You can configure TRAMP to respect the PATH variable on the remote machine (for remote eshell sessions) by adding 'tramp-own-remote-path to the list 'tramp-remote-path: (add-to-list 'tramp-remote-path 'tramp-own-remote-path) ...


5

Eshell and shell-mode both use ansi-color.el to turn ansi color codes into faces. ansi-color.el supports the following faces: Parameter Description Face used by default 0 default default 1 bold bold 2 faint default 3 italic italic 4 underlined ...


5

This does it to one, insted of two lines. ;Clear the eshell buffer. (defun eshell/clear () (let ((eshell-buffer-maximum-lines 0)) (eshell-truncate-buffer))) Typing clear in eshell will then result in clearing the buffer.


5

(setq eshell-scroll-to-bottom-on-input t) should do what you want.


5

I recently started using emacs outside of the terminal which was causing me some PATH issues. I had tried setting it by adding (getenv "PATH") to my exec-path, among other things that ultimately never worked. I ended up installing the exec-path-from-shell package via melpa. It works by using your $SHELL environment variable to ask your shell to print out ...


5

You can use shell-command-to-string to get a shell command's output. From C-h f shell-command-to-string: shell-command-to-string is a compiled Lisp function in ‘simple.el’. (shell-command-to-string COMMAND) Execute shell command COMMAND and return its output as a string. For example, on my machine, your shell command gives (let ((default-...


5

The following saves cd history and provides eshell commands b and f to navigate that history: ;;*--- track cd history ------------------------------------------------*/ (defvar-local eshell-hist-dirs nil) (add-hook 'eshell-directory-change-hook (defun eshell-update-hist-dir () (push (eshell/pwd) eshell-hist-dirs) (setq ...


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