Skip to content

Emacs eshell Snippets

;; Check command being used with which
which ls
;; Open dired to current directory or specific path
dired ..
dired PATH
;; See file
view-file filename
;; Edit file
find-file filename
;; Output of command to kill-ring (clipboard history)
rg ID >/dev/kill
;; Output of command to a separate named buffer
rg -i string > #<buffername>
;; Output of last command to clipboard, run multiple commands with ;
echo $$ >/dev/clip; echo hello
;; Run 2 commands only if first command successful
echo hello && echo world
;; Grep all files in directory, open in Emacs grep mode
grep PATTERN *
;; Evalute subshell commands
echo $(+ 1 2 3)
;; Parse agrument string into elisp notation
listify 1 2 3
;; Add path to $PATH environment variable or print existing paths if no argumment
addpath PATH
;; Unset, remove environment variable
unset ENV-VAR
;; magit status of directory
magit
;; Convert string to upper or lowercase
upcase STRING
downcase STRING
;; Status of version controlled directory
vc-dir DIRECTORY
;; Diff two files
ediff-files FILE1 FILE2
;; Alias Setting
alias ff 'find-file $1'
;; Run command in background if external to Emacs
external-command &
;; Search for file name with emacs in current directory using * glob
find-name-dired ./ *emacs*
;; Start command in background asynchronously
curl hello.org &
;; Run eshell commands in a batch file with eshell-batch-file
#!/usr/bin/env -S emacs --batch -f eshell-batch-file
;; List recent directories
cd =
;; Go to listed directory by number
cd -0
;; SSH, cd into Docker containers
ssh server
;; Common Commands re-implemented by eshell
cat, cp, ls, cd, export, dirs, du, echo, env, kill, ln, mkdir, mv, alias, popd, pushd, pwd, rm, rmdir, time, umask