URL handler
What's this?
zsh widget and functions extended from widget introduced in Crouton's diary (japanese). You can enter URL directly in console, and browse or download it.
Features
- prompt browse or download
- auto download when URL has some specific suffix
- auto select browse or download
- Can handle FTP (and other...)
Sample Usage
Browse URL simply
sugi@tempest:~% http://slashdot.jp/ [Enter]
Type URL and Hit [Enter]...
sugi@tempest:~% _resolv_url http://slashdot.jp/ Browse or Download this URL? [B/d] [Enter]
Prompt displayed. choice one. ([Enter] for upper case letter)
sugi@tempest:~% _resolv_url http://slashdot.jp/ Browse or Download this URL? [B/d] sugi@tempest:~% Message: Galeon already running, using existing process
URL has been sent to galeon.
Auto download when URL has some suffix
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]
Install and minimal setting
- download and extract file
- copy functions/* to directory specified as fpath
- add following setting to
~/.zshrc
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
Customise
WWW_BROWSER (env) : your browser (default: www-browser). %s will replace to URL. ex: export WWW_BROWSER="netscape-remote %s"
DOWNLOADER (env) : your downloader (default: wget). ex: export DOWNLOADER="wget -nv"
browse_or_download_method (shell var) : following value affected.
"ask"or empty — ask method every time (default)"auto"— auto select default method"download"or"browse"— always so
ex: browse_or_download_method="auto"
Configuration sample
~/.zshrc
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
~/.zshenv
if [[ -z "$DISPLAY" ]]; then export WWW_BROWSER="w3m" else export WWW_BROWSER="galeon -n %s &!" fi export DOWNLOADER="wget -S"