Friday, August 05, 2005

get rid of ^A ^B in emacs ipython shell

add in .emacs:
(add-hook 'comint-mode-hook
'(lambda ()
(add-hook 'comint-output-filter-functions
'shell-filter-ctrl-a-ctrl-b nil t)))
(defun shell-filter-ctrl-a-ctrl-b (string)
"Remove `^A' and `^B' characters from comint output.
These characters may show up in the prompt of bash, due to a bug in
bash. If you experience this problem, put this function in
`comint-output-filter-functions'."
(let ((pmark (process-mark (get-buffer-process (current-buffer)))))
(save-excursion
(goto-char (or comint-last-output-start (point-min)))
(while (re-search-forward "[\C-a\C-b]" pmark t)
(replace-match "")))))