| JAPANESE | ENGLISH |
小澤氏の日記で紹介されていた、zsh ウィジェット を少し拡張したものです。プロンプトにそのまま URL を打ちこんで Enter を押せば、 ブラウザで表示したり、ダウンロードが可能。
sugi@tempest:~% http://shlashdot.jp/ [Enter]
URL を入力して Enter を押すと、
sugi@tempest:~% _resolv_url http://shlashdot.jp/ Browse or Download this URL? [B/d] [Enter]
プロンプトが表示されるので、どちらかを選択。(Enter で大文字の方を選択)
sugi@tempest:~% _resolv_url http://shlashdot.jp/ Browse or Download this URL? [B/d] sugi@tempest:~% Message: Galeon already running, using existing process
URL が galeon に送られる。
sugi@tempest:~% http://ftp.us.debian.org/debian/pool/main/b/base-files/base-files_3.0.2_i386.deb Enter]
Browse or Download this URL? [b/D] [Enter]
--09:12:55-- http://ftp.us.debian.org/debian/pool/main/b/base-files/base-files_3.0.2_i386.deb
=> `base-files_3.0.2_i386.deb'
Resolving ftp.us.debian.org... done.
Connecting to ftp.us.debian.org[35.9.37.225]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30,956 [application/x-debian-package]
100%[====================================>] 30,956 55.17K/s ETA 00:00
09:12:56 (55.17 KB/s) - `base-files_3.0.2_i386.deb' saved [30956/30956]
if autoload +X -U _accept_line_with_url > /dev/null 2>&1; then
zle -N accept-line-with-url _accept_line_with_url
bindkey '^M' accept-line-with-url
bindkey '^J' accept-line-with-url
fi
export WWW_BROWSER="nescape-remote %s"
export DOWNLOADER="wget -nv"
プロンプトを出すかどうかを変更する。以下の値が有効。
例: browse_or_download_method="auto"
if [ -d ~/lib/zsh/functions ]; then
fpath=(~/lib/zsh/functions $fpath)
fi
......(snip).......
if autoload +X -U _accept_line_with_url > /dev/null 2>&1; then
zle -N accept-line-with-url _accept_line_with_url
bindkey '^M' accept-line-with-url
bindkey '^J' accept-line-with-url
fi
if [[ -z "$DISPLAY" ]]; then export WWW_BROWSER="w3m" else export WWW_BROWSER="galeon -n %s &!" fi export DOWNLOADER="wget -S"