开发者

cygwin shell in Emacs - output messed up?

开发者 https://www.devze.com 2023-01-18 07:23 出处:网络
I saw an answer here how to start the cygwin shell. However, the cygwin shell output is messed up. (defun cygwin-shell ()

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?


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)


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号