diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 1ec84e865..fd80880e9 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -74,6 +74,35 @@ This is useful when prompt unexpectedly changes."
       (setq comint-prompt-regexp org-babel-comint-prompt-regexp-old
             org-babel-comint-prompt-regexp-old tmp))))
 
+(defun org-babel-comint-process-output-filter (from-string &optional to-remove remove-echo)
+  "Remove string FROM-STRING from TO-REMOVE.
+
+TO-REMOVE defaults to `comint-prompt-regexp'.  REMOVE-ECHO
+removes echoed commands some shells may print and defaults to t."
+  (let* ((to-remove (or to-remove comint-prompt-regexp))
+         (remove-echo (or remove-echo t)))
+    ;; remove TO-REMOVE from FROM-STRING
+    (while (string-match-p to-remove from-string)
+      (setq from-string
+            (replace-regexp-in-string
+             (format
+              "\\(?:%s\\)?\\(?:%s\\)[ \t]*"
+              "org-babel-comint-process-output-filter-separator\n"
+              to-remove)
+             "org-babel-comint-process-output-filter-separator\n"
+             from-string)))
+    ;; remove echo
+    (when (and remove-echo from-string ; <-- FIXME from-string needs to be block body
+               (string-match
+                (replace-regexp-in-string
+                 "\n" "[\r\n]+" (regexp-quote (or from-string "")))
+                from-string))
+      (setq from-string (substring from-string (match-end 0))))
+    (delete "" (split-string
+                from-string
+                "org-babel-comint-process-output-filter-separator\n"))
+    ))
+
 (defmacro org-babel-comint-with-output (meta &rest body)
   "Evaluate BODY in BUFFER and return process output.
 Will wait until EOE-INDICATOR appears in the output, then return
@@ -139,31 +168,35 @@ or user `keyboard-quit' during execution of body."
 	 (goto-char (process-mark (get-buffer-process (current-buffer))))
 	 (insert dangling-text)
 
-         ;; Filter out prompts.
-         (while (string-match-p comint-prompt-regexp string-buffer)
-           (setq string-buffer
-                 (replace-regexp-in-string
-                  ;; Sometimes, we get multiple agglomerated
-                  ;; prompts together in a single output:
-                  ;; "prompt prompt prompt output"
-                  ;; Or even "<whitespace>prompt<whitespace>prompt ...>.
-                  ;; Remove them progressively, so that
-                  ;; possible "^" in the prompt regexp gets to
-                  ;; work as we remove the heading prompt
-                  ;; instance.
-                  (format "\\(?:%s\\)?\\(?:%s\\)[ \t]*" ,org-babel-comint-prompt-separator comint-prompt-regexp)
-                  ,org-babel-comint-prompt-separator
-                  string-buffer)))
-	 ;; remove echo'd FULL-BODY from input
-	 (when (and ,remove-echo ,full-body
-		    (string-match
-		     (replace-regexp-in-string
-		      "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
-		     string-buffer))
-	   (setq string-buffer (substring string-buffer (match-end 0))))
-         (delete "" (split-string
-                     string-buffer
-                     ,org-babel-comint-prompt-separator))))))
+         (org-babel-comint-process-output-filter string-buffer)
+         
+         ;; ;; Filter out prompts.
+         ;; (while (string-match-p comint-prompt-regexp string-buffer)
+         ;;   (setq string-buffer
+         ;;         (replace-regexp-in-string
+         ;;          ;; Sometimes, we get multiple agglomerated
+         ;;          ;; prompts together in a single output:
+         ;;          ;; "prompt prompt prompt output"
+         ;;          ;; Or even "<whitespace>prompt<whitespace>prompt ...>.
+         ;;          ;; Remove them progressively, so that
+         ;;          ;; possible "^" in the prompt regexp gets to
+         ;;          ;; work as we remove the heading prompt
+         ;;          ;; instance.
+         ;;          (format "\\(?:%s\\)?\\(?:%s\\)[ \t]*" ,org-babel-comint-prompt-separator comint-prompt-regexp)
+         ;;          ,org-babel-comint-prompt-separator
+         ;;          string-buffer)))
+	 ;; ;; remove echo'd FULL-BODY from input
+	 ;; (when (and ,remove-echo ,full-body
+	 ;;            (string-match
+	 ;;             (replace-regexp-in-string
+	 ;;              "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
+	 ;;             string-buffer))
+	 ;;   (setq string-buffer (substring string-buffer (match-end 0))))
+         ;; (delete "" (split-string
+         ;;             string-buffer
+         ;;             ,org-babel-comint-prompt-separator))
+
+         ))))
 
 (defun org-babel-comint-input-command (buffer cmd)
   "Pass CMD to BUFFER.
@@ -324,8 +357,9 @@ STRING contains the output originally inserted into the comint buffer."
 		      until (and (equal (match-string 1) "start")
 				 (equal (match-string 2) uuid))
 		      finally return (+ 1 (match-end 0)))))
-		   ;; Apply callback to clean up the result
-		   (res-str (funcall org-babel-comint-async-chunk-callback
+                   ;; Apply filter to clean up the result
+                   (res-str ;(funcall org-babel-comint-async-chunk-callback
+                             (org-babel-comint-process-output-filter
                                      res-str-raw)))
 	      ;; Search for uuid in associated org-buffers to insert results
 	      (cl-loop for buf in org-buffers
