Eshell/shell
#emacs Cheatsheets/TILs
Pressing RET anywhere executes that line. For example, when Guix tells you to reload GUIX_PROFILE
, it prints out the commands to do so. So you can simply… go there with the cursor and press RET! It's so stupid yet so good.
Cool hotkeys
- C-c C-p -> return to top of last command
- C-c M-b inserts the printed buffer name at point
- C-c M-i inserts the printed process name at point
- C-c M-v inserts an env var at point
- C-c M-d toggles betw direct input and delayed input (send on RET) (useful for some programs) (<2020-Apr-23>: is this basically for y/n prompts?)
(defun eshell-here () "Opens up a new shell in the directory associated with the current buffer's file. The eshell is renamed to match that directory to make multiple eshell windows easier." (interactive) (let* ((parent (if (buffer-file-name) (file-name-directory (buffer-file-name)) default-directory)) (height (/ (window-total-height) 3)) (name (car (last (split-string parent "/" t))))) (split-window-vertically (- height)) (other-window 1) (eshell "new") (rename-buffer (concat "*eshell: " name "*")) (insert (concat "ls")) (eshell-send-input))) ;; My function, x exits that shell and closes that window. (defun eshell/x () (insert "exit") (eshell-send-input) (delete-window))
Programs like
top
wouldn’t work well in Eshell […] However, if you type top, eshell notices top on its naughty list (the list is calledeshell-visual-commands
), and will farm it out to a special comint buffer. If you find an app that doesn’t work well in EShell, append it to this list.It is not bash or zsh or even csh; do not treat it as such, even though it is heavily inspired by them. To use Eshell effectively you should treat it as if you are using a completely alien shell.
–Howard Abrams
Argument predicates are a cool way of quickly filtering lists of files or even elisp lists. The predicate syntax is based on the one used in zsh, so if you are familiar with argument predication in zsh, you can apply most of your knowledge to Eshells’ version.
Unlike most other areas of Eshell, argument predicates are documented in Eshell itself. You can access the help files by typing
eshell-display-predicate-help
oreshell-display-modifier-help
(directly in eshell of course).Filtering globbed lists of files is very useful, as it saves you the hassle of using tools like find or abusing ls to do your thing.