fixed a bug that occurred when the eshell command has a string in
it. the README got updated.
This commit is contained in:
parent
6dbd467632
commit
d1fa441e8c
23
README.org
23
README.org
|
@ -1,9 +1,28 @@
|
|||
* What is it?
|
||||
Right now it has just a history-macro functionality. That means you can say: "I want to make my last 3 eshell commands into a macro."
|
||||
|
||||
* How to use it?
|
||||
* How to install it?
|
||||
To use eshell-tricks you should copy the eshell-tricks folder into your .emacs.d directory.
|
||||
Then add the following lines to your init.el (or .emacs)
|
||||
Then add the following lines to your init.el (or .emacs):
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(load-file "~/.emacs.d/eshell-tricks/eshell-tricks.el")
|
||||
(setq eshell-tricks-file "~/.emacs.d/eshell-tricks/eshell-tricks-macros.el")
|
||||
#+END_SRC
|
||||
|
||||
* How to use it?
|
||||
Just do your usual eshell hacking. Wenn you realise you are repeating a series of commands more often you can
|
||||
write them in a macro with eshell/etricks-record. This is an example on how to do that:
|
||||
#+BEGIN_SRC sh
|
||||
~ $ cd example
|
||||
~/example $ touch test
|
||||
~/example $ ls -a
|
||||
. .. test
|
||||
~/example $ (eshell/etricks-record 'my-name 2 nil)
|
||||
~/example $ (my-name)
|
||||
. .. test
|
||||
~/example $
|
||||
#+END_SRC
|
||||
In the above example we told the eshell/etricks-record function to create a macro for us. The created macro
|
||||
executes the last 2 shell commands in the order they were called in (counting starts from the function call).
|
||||
'my-name is the name of the new macro and nil means we don't want to make the macro always execute in the current
|
||||
directory.
|
||||
|
|
|
@ -14,8 +14,6 @@ BUF-NAME can pass the name of the new buffer."
|
|||
(insert-buffer-substring cur-buf prompt-pos end-pos))
|
||||
(switch-to-buffer-other-frame new-buf)))
|
||||
|
||||
|
||||
|
||||
(defun etricks-handle-eshell-return (RETURN-VALUE)
|
||||
"Returns a simple string from the executed eshell command (you give it the returned object as RETURN-VALUE).
|
||||
That's needed because e.g. elisp expressions might just return nil or a list or something."
|
||||
|
@ -24,13 +22,14 @@ BUF-NAME can pass the name of the new buffer."
|
|||
(throw 'etricks-handle-eshell-return-exit (substring-no-properties RETURN-VALUE))
|
||||
(throw 'etricks-handle-eshell-return-exit (format "%s" RETURN-VALUE)))))
|
||||
|
||||
|
||||
(defmacro etricks-backwards-macro (FUNC-NAME ESHELL-COMMANDS &optional DIRECTORY)
|
||||
"Returns the ESHELL-COMMANDS in a functinion with FUNC-NAME."
|
||||
`(defun ,FUNC-NAME ()
|
||||
(let ((default-directory (or ,DIRECTORY default-directory)))
|
||||
(apply #'concat (mapcar #'substring-no-properties
|
||||
(mapcar #'eshell-command-result ',ESHELL-COMMANDS))))))
|
||||
(apply #'concat (mapcar (lambda (x) (if (null x)
|
||||
(progn nil)
|
||||
(substring-no-properties x)))
|
||||
(mapcar #'eshell-command-result ',ESHELL-COMMANDS))))))
|
||||
|
||||
(defun eshell/etricks-record (FUNC-NAME N &optional USE-DIRECTORY)
|
||||
"Saves the last N eshell commands as a function named FUNC-NAME in the file
|
||||
|
|
Loading…
Reference in New Issue