2011年11月14日月曜日

仮想コンソールでの文字化けを何とかしたい

 仮想コンソールで日本語が文字化けするのを直すには、~/.bashrcに次を追記
case $TERM in
linux) LANG=C ;;
*) LANG=ja_JP.UTF-8 ;;
esac
で、次のコマンドを実行して適用。
source .bashrc 
これで、エンコードが英語になる。

→と思ったら、ログインし直すとまた□の嵐…どういう事…

追記:
bashの初期化の際に、~/.profileというファイルが環境設定として読み込まれるようです。
.profileを覗いてみると、.bashrcを読み込んでから、.profile自体に書かれた処理をするようなのですが、.bashrcを読み込んだあとに、
export LANG="ja_JP.UTF-8"
export LANGUAGE="ja:en_GB:en"
export LC_MESSAGES="ja_JP.UTF-8"
export LC_CTYPE="ja_JP.UTF-8"
export LC_COLLATE="ja_JP.UTF-8";;
とご丁寧に、.bashrcで設定したのを上書きしちゃってくれてます。
ってことで、.bashrcの方のLANG=Cの部分は消しちゃって、
case "$TERM" in
linux)
export LANG="C"
export LANGUAGE="C"
export LC_MESSAGES="C"
export LC_CTYPE="C"
export LC_COLLATE="C";;
*)
export LANG="ja_JP.UTF-8"
export LANGUAGE="ja:en_GB:en"
export LC_MESSAGES="ja_JP.UTF-8"
export LC_CTYPE="ja_JP.UTF-8"
export LC_COLLATE="ja_JP.UTF-8";;
esac
と追記すれば、仮想コンソールでは英語で、それ以外の分では日本語で、とできます。
解決解決。

参考にしたサイト
http://viva-ubuntu.com/?p=1707
(ML)
https://lists.ubuntu.com/archives/ubuntu-jp/2011-November/003934.html

2011年11月10日木曜日

しろろさんぼっとリリースノート/Release note for shiroro_3_bot

概要
しろろさん(Twitter:@shiroro_3)のつぶやきの中から、管理人である私が独断と偏見でチョイスしたものをツイートします。
》現在、ツイート内容を増強中です。また、純度向上にも務めています。《
リプライ機能もつけていきたいと思っています。
しろろさんぼっとはランダムリプライ機能を搭載しています。しろろさんぼっとにメンションを投げると、しろろさんがいままで行ったリプライツイートの中からランダムでリプライを行います。支離滅裂な会話を楽しみたい方はお試しください。

バージョン
ver.12.01-11a
パターン数を増やしました(定期:+41 リプライ:+7)

ver.11.12-13a
パターン数を増やしました

ver.11.11.28a
パターン数を増やしました(定期:+73 リプライ:+29)

ver.11.11.17a
パターン数を増やしました(+33)
ランダムリプライ機能を付けました(約140パターン)
特定のワードに対応するリプライ機能は廃止しました。

ver.11.11.12a
パターン数を増やしました(+7)

ver.11.11.11a
つぶやきの頻度の変更(4posts/day→8posts/day)

ver.11.11.10c
パターンを整理しました(削除:6)
パターンを増やしました(8くらい)

ver.11.11.10b
つぶやき頻度の変更(2posts/h→4posts/day)

ver.11.11.10a
アイコンの色の調整。

ver.11.11-09d
アイコンの色の調整。

ver.11.11-09c
バージョン番号の管理方法を変更。
リプライ機能搭載(2種類)

ver.11.11-09b(0.15)
パターン増強(約140)。
bot用アイコンを作成。
つぶやき頻度の変更(1post/h→2posts/h)

ver.11.11-09a(0.10)
botを作成。
パターンは50~60程度。


Overview
shiroro_3_bot tweets the choicest tweets which shiroro-san(whose twitter account is  @shiroro_3) posted. They are chosen by the administrator, me.
>> I am engaged in increasing the quantity and developing the quality of the tweet patterns NOW. <<
I make some effort to increase the reply patterns.
Shiroro_3_bot has the randam reply function. If you post to the bot, it will post a reply to you, which Shiroro-san has posted as a reply.

Versions


ver.12.01-11a
New patterns are added (regular:+41 replies:+7)

ver.11.12-13a
Some new patterns are added


ver.11.11.28a
New patterns are added (regular:+73 replies:+29)


ver.11.11.17a
New 33 patterns added.
Random reply function equipped.(Approximately 140 patterns)
The reply function for specific terms removed.

ver.11.11.12a
New 7 patterns added.

ver.11.11.11a
The frequency of the tweets was changed.(4 posts/day→8 posts/day)

ver.11.11.10c
The quality of patterns was improved. (6 patterns removed)
Some patterns added (about 8)

ver.11.11.10b
The frequency of the tweets was changed.(2 posts/h→4 posts/day)

ver.11.11.10a
The colors of the icon was adjusted.

ver.11.11-09d
The colors of the icon was adjusted.

ver.11.11-09c
The rule about the number of version was changed.
The reply function was equipped (2 patterns).

ver.11.11-09b(0.15)
The number of tweet patterns was increased (approximately 140 patterns).
The icon was created.
The frequency of the tweets was changed(1post/h→2posts/h).

ver.11.11-09a(0.10)
The bot was created.
The bot had approximately 50 - 60 tweet patterns.

2011年11月9日水曜日

簡易全文検索シェルスクリプト ver.2

この間、簡易全文検索シェルスクリプトを作ったけど、実際つかてみると1単語しか検索できないという使えない感丸出しなので複数単語にも対応させてみた。たぶんいけてる。
#!/bin/bash
if [ $1 != "" ];then
words=$@
echo "${words}"
echo "Results"
echo "---------------------------------------------------------------------------"
echo $'\n'
for fn in *.txt
do
grep "${words}" ${fn} -n --color=always -2 -i
ret=$?
if [ ${ret} -eq 0 ]
then
echo ---------------------------------------------------------------------------in ${fn};
echo $'\n'
fi
done
else
echo "there is no argument"
fi

2011年11月3日木曜日

簡易全文検索シェルスクリプト

tesseractで画像ファイルから文字を抽出したので、全文検索機能も付けたくなったのでいろいろ検討。
Namazuとかも考えたけど、身の丈にあったもの、というかそんなたいそうなものいらないんじゃね、ってことでgrep+シェルスクリプトで簡単に作ってみた。
#search.sh
#!/bin/bash
if [ $1 != "" ];then
echo "Results"
echo "---------------------------------------------------------------------------"
echo $'\n'
for fn in *.txt
do
grep $1 ${fn} -n --color=always -2 -i
ret=$?
if [ ${ret} -eq 0 ];then
echo ---------------------------------------------------------------------------in ${fn}
echo $'\n'
fi
done
else
echo "there is no argument"
fi
  1. 引数なしだとエラーが出るように。
  2. 行数とファイル名が出るように。
  3. 当該箇所は赤字で表示。
は出来てるからいいんじゃないかなー。
賢いスクリプトじゃないとは思うけど、とりあえず満足。