お知らせ

  • 利用規約を守って投稿してください。また、よくある質問および投稿の手引きも参照してください。
  • メッセージの投稿にはアカウントが必要です。未登録の方は、ユーザ登録ページからアカウントを作成することができます。

#1 2009-03-30 08:16:25

kei0625
メンバ
登録日: 2009-02-19

Emacsでのshellモード

よろしくお願いします。

Emacsでのshellモードで、lsコマンドを実行すると、以下のように文字化けが起こってしまいます。

#emacs1#      c1.c~         emacs2        numerical     shellscript6  公開
DD385D79.gpg  calc1-utf8.c  emacs2~       shellscript1  shellscript7  雛形
Examples      data1         emacs3        shellscript2  sort-k2       動画
a.out         data2         emacs3~       shellscript3  デスクトップ  文書
c.c           emacs1        install       shellscript4  音楽
c1.c          emacs1~       mailの下書き  shellscript5  画像

一方、端末で同じことを行うと、以下のように表示されます。

#emacs1#      c1.c~         emacs2        numerical     shellscript6  公開
DD385D79.gpg  calc1-utf8.c  emacs2~       shellscript1  shellscript7  雛形
Examples      data1         emacs3        shellscript2  sort-k2       動画
a.out         data2         emacs3~       shellscript3  デスクトップ  文書
c.c           emacs1        install       shellscript4  音楽
c1.c          emacs1~       mailの下書き  shellscript5  画像

defaultのフォントは、端末のdefaultフォントと同じ、Monospaceの10を使っているのですが、なぜか文字化けが起こります。
もし、同じような経験をお持ちで、解決方法が分かる方がいらっしゃいましたら、アドバイスをお願いしたいと思います。

オフライン

 

#2 2009-03-30 09:51:01

hito
管理者
登録日: 2007-03-18

Re: Emacsでのshellモード

shell-modeの代わりにansi-termを使ってください。
shell-modeはエスケープシーケンスを含め、多くの文字表示が期待した通りには行われません。

オフライン

 

#3 2009-03-30 10:55:53

einundzwanzighundertsechs
メンバ
登録日: 2008-12-28

Re: Emacsでのshellモード

エスケープシークエンスを解しない他の端末に出会った時の参考までに.
;; ansi-term は初めて知りました.hito さん,有り難うございます.

shell モードでも ls の --color オプションを無効にすれば ls に関しては#1のエスケープシークエンスは使われません.
ログインした状態で ls の alias 設定がおそらく
$ alias ls
alias ls='ls --color=auto'
となっているので,
$ \ls
で ls を使うか,
$ unalias ls
で alias を無効にするか.

追加:
shell モードはダム端末になってるのですね.
$ printenv TERM
dumb
.bashrc を次のように編集して,ダム端末では色を使わないようにする.

コード:

diff -u /etc/skel/.bashrc ~/.bashrc 
--- /etc/skel/.bashrc    2008-05-13 03:48:01.000000000 +0900
+++ /home/hoge/.bashrc    2009-03-30 12:24:11.000000000 +0900
@@ -75,7 +75,7 @@
 #fi
 
 # enable color support of ls and also add handy aliases
-if [ -x /usr/bin/dircolors ]; then
+if [ "$TERM" != dumb -a -x /usr/bin/dircolors ]; then
     eval "`dircolors -b`"
     alias ls='ls --color=auto'
     #alias dir='dir --color=auto'

最後の編集者: einundzwanzighundertsechs (2009-03-30 12:47:21)

オフライン

 

#4 2009-03-30 11:40:30

mizuno
管理者
From: Kyoto
登録日: 2007-02-28

Re: Emacsでのshellモード

.emacsにこんなのを書いておくとか。

コード:

(autoload 'ansi-color-for-comint-mode-on "ansi-color"
          "Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

オフライン

 

#5 2009-03-31 08:31:03

kei0625
メンバ
登録日: 2009-02-19

Re: Emacsでのshellモード

hitoさん、mizunoさん、einundzwanzighundertsechsさん、ご返事ありがとうございます。

hito による投稿:

shell-modeの代わりにansi-termを使ってください。

問題はこれで、解決しました。

オフライン

 

Board footer

Powered by FluxBB