Top/article/Command-line-dict
English | Japanese
English | Japanese

Menu

  • Top
  • Akihiko Yamaguchi 山口 明彦
  • Project プロジェクト
  • Text テキスト
  • Recent articles 最近の記事
  • Articles 記事一覧 (a to z)
  • Search 検索

Tags タグ †

  • [c++][bash][python][latex][php]
  • [linux][windows][mac][android]
  • [math][algorithm][idea][trick]
  • [liboctave][opencv][git][ros]
  • [setting][bug][general]
↑

Recent articles 最近の記事 †

2019-07-02
  • article/Display-Unix-Time
  • article/Synchronize-Linux-Time-to-Remote
2018-09-27
  • article/python-multimode-singleton
2018-09-02
  • article/rosinstall-git-default-remote
2017-07-28
  • article/SubMenu
2017-03-05
  • article/Import-a-different-version-of-OpenCV-in-Python
2015-08-17
  • article/DRC-finals-2015
2015-01-05
  • article/Upgrade-Android-to-Lollipop
2015-01-01
  • article/Kernel-panic-of-Linux-when-using-Xtion
  • article/Do-not-skip-freeing-data-when-using-tri-mesh-in-ODE
Access: 2/2621 - Admin

Command line dictionary

コマンドライン辞書

[bash]
2008-06-29
2010-04-16

linux のコマンドラインで

% ej dictionary

とか打つだけで,英辞郎 on the Webの検索結果が表示されると便利だ. そんなシェルスクリプトが32nd Diary (2005/08/26)で紹介されていたので,日本語とか熟語が使えるようにしてみた:

  • 修正(@Jan.01,2009): sed のパタンを一部修正.
  • さらに修正(@Apr.16,2010): sed のパタンをかなり修正

ej

#!/bin/bash
# http://taka.no32.tk/diary/20050826.html
KEY=`echo $@ | nkf -w -w80`
echo $@ >> ~/.eng-list
URI="http://eow.alc.co.jp/$KEY/UTF-8/"
RS=`echo '▼ 検索結果本体 ▼' | nkf -w -w80`
RE=`echo '▲ 検索結果本体 ▲' | nkf -w -w80`
wget -q --referer='http://eow.alc.co.jp/' \
     -U 'Mozilla/5.0' -O - "$URI" | \
sed -ne "/<!--\s*$RS\s*-->/,/<!--\s*$RE\s*-->/p" | w3m -dump -T 'text/html' | $PAGER

これを ~/bin/ej とかに保存してパスを通し,

% ej dictionary
% ej take for
% ej 辞書

みたいに使う.~/.eng-list に履歴が保存される.

最近はGoogle翻訳が便利なので,軽量ブラウザ midori をアプリモードで呼び出すようなスクリプトも作ってみた.

gt

#!/bin/bash
q=$@
encode=$(echo "$q"|nkf -g)
if [ $encode == "ASCII" ];then
  src_lang=en
  dest_lang=ja
else
  src_lang=ja
  dest_lang=en
fi

midori -a "https://translate.google.com/?source=gtx#$src_lang/$dest_lang/$q" >& /dev/null &



Last-modified:2014-12-31 (Wed) 17:01:41 (3822d)
Link: article/Seven-tools-for-writing-papers(3822d)
Site admin: Akihiko Yamaguchi.
Written by: Akihiko Yamaguchi.
System: PukiWiki 1.5.0. PHP 5.2.17. HTML conversion time: 0.295 sec.