JAPANESEENGLISH

zsh customize

Tatsuki Sugiura
sugi@nemui.org

Table of contents

URL handler

What's this?

zsh widget and functions extened from widget introducted in Crouton's diary(japanese). You can enter URL directly in console, and browse or download it.

Features

Sample Usage

Browse URL simply

sugi@tempest:~% http://shlashdot.jp/ [Enter]

Type URL and Hit [Enter]...

sugi@tempest:~% _resolv_url http://shlashdot.jp/
Browse or Download this URL? [B/d] [Enter]

Prompt displayed. choice one. ([Enter] for upper case letter)

sugi@tempest:~% _resolv_url http://shlashdot.jp/
Browse or Download this URL? [B/d] 
sugi@tempest:~% Message: Galeon already running, using existing process

URL has been sended to galeon.

Auto dwonload 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

  1. download and extract file
  2. copy functions/* to directory specified as fpath
  3. 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 (defualt: 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

Download