Seth
Seth

Reputation: 111

cygwin shell in Emacs - output messed up?

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?

Upvotes: 4

Views: 1471

Answers (4)

Derek Wang
Derek Wang

Reputation: 11

Use

export PS1="\e[0;32m\u@\h\e[m \e[0;33m\w\e[m\n\$ "

If you like to keep the original color and format.

Upvotes: 1

Jeff Jackson
Jeff Jackson

Reputation: 21

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

Upvotes: 2

Laurynas Biveinis
Laurynas Biveinis

Reputation: 10848

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.

Upvotes: 1

Seth
Seth

Reputation: 111

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)

Upvotes: 4

Related Questions