Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cygwin shell in Emacs - output messed up?

Tags:

emacs

cygwin

I saw an answer here how to start the cygwin shell. However, the cygwin shell output is messed up.

(defun cygwin-shell ()
  "Run cygwin bash in shell mode."
  (interactive)
  (let ((explicit-shell-file-name "C:/cygwin/bin/bash"))
    (call-interactively 'shell)))
(setq  explicit-bash-args '("--login" "-i"))

and here is a sample output of the shell

]0;~
seth@seth ~
$ cd ~
]0;~
seth@seth ~
$ dir
]0;~
seth@seth ~

as one can see, output is screwed up. How do i fix this?

edit: i just noticed that ^[]0 always appears at the end of each command \ otherwise output text works fine. Anyway to get rid of this ending?

like image 593
Seth Avatar asked Oct 02 '10 23:10

Seth


3 Answers

alright, i figured this out. in ~/.bashrc, i added

export PS1="\e[0;31m[\u@\h \W]\$ \e[m "

this makes prompt red in single line (which is easy on eyes vs the yellow in original cygwin prompt!)

see http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

In addition, you have to make sure you do not use dos endings. To convert dos endings to unix, type C-x RET f unix and save or place in .emacs file

(set-buffer-file-coding-system 'unix)
like image 199
Seth Avatar answered Nov 15 '22 03:11

Seth


Look into EmacsW32. With it, your .emacs configuration becomes

  (setq w32shell-cygwin-bin "c:\\cygwin\\bin")
  (require 'w32shell)
  (w32shell-add-emacs)
  (w32shell-set-shell "cygwin")

and everything works.

like image 26
Laurynas Biveinis Avatar answered Nov 15 '22 03:11

Laurynas Biveinis


In Emacs 24.2, I had to put the export PS1=... line from Seth's answer (2) in ~/.emacs_bash instead of in ~/.bashrc.

like image 30
Jeff Jackson Avatar answered Nov 15 '22 04:11

Jeff Jackson