If I'm in eshell I can run elisp commands cause I'm in an elisp runtime

(mapcar (lambda (x) (* x 3)) (list 1 2 3))
(3 6 9)

I can also run "shell" commands such as git status. But what if I wanted to take the output of my git status and pass it into a mapcar. How would I do that?

  • How about?: (let ((result (shell-command-to-string "git status"))) (stringp result)) That example will return t at the eshell command prompt. In terms of plugging that into your example, more details would be needed to know whether the result needs to be converted to a list for the SEQUENCE argument of mapcar or whether it would be plugged into the FUNCTION argument of mapcar.
    – lawlist
    Jun 26, 2017 at 22:28
  • shell-command-to-string seems to be what I needed (I'm just going to split by newline) Thanks! If you move it to an answer I'll mark it as answered. Jun 26, 2017 at 22:36

1 Answer 1


For something simple, shell-command-to-string may suffice. For something more complicated where the output needs to be modified, searched, etc., then something more elaborate may needed e.g., set-process-sentinel; start-process; set-process-filter, etc. and then take the result and plug it in. The following example will return t because the output of git status has been converted to a string using shell-command-to-string and the output in the example is tested with stringp.

(let ((result (shell-command-to-string "git status")))
  (stringp result))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.