From: Bart Schaefer <schaefer@brasslantern.com>
To: Shao Zhang <shao@linux.cia.com.au>
Cc: ZSH Mail List <zsh-users@sunsite.auc.dk>
Subject: Re: [OT] export http_proxy
Date: Thu, 15 Jun 2000 14:42:30 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.20.0006151411040.23750-100000@aztec.zanshin.com> (raw)
In-Reply-To: <20000616023433.A7142@localhost>
On Fri, 16 Jun 2000, Shao Zhang wrote:
> I have a couple of isps on my linux box, and some of them need a
> proxy setting. So nearly everytime I dial up, I have to export the
> http_proxy in order to use it. Now is there an easy/smart way to do
> this rather than doing it manually?
Use the `preexec' user-defined function. You need to devise a test that
zsh can use to determine to which ISP you're presently connected; perhaps
something like
function preexec() {
case ${${(M)$(ifconfig ppp0):#addr:*}#addr:} in
192.168.68.1) export HTTP_PROXY=192.168.68.215;;
192.168.86.9) typeset +x HTTP_PROXY; unset HTTP_PROXY;;
and-so-on) export HTTP_PROXY=and-so-forth;;
esac
}
However, it might be a bit expensive to run ifconfig before each and every
command, so you might instead try putting it in the `periodic' function
(so it gets updated every $PERIOD seconds, which you also need to set).
Or you could put it in a trap handler for e.g the USR2 signal and have a
script that runs when PPP comes up that does a "killall -USR2 zsh" to
cause all shells to update their environment.
To explain those hierographics (PWS's word) a bit:
$(ifconfig ppp0) Run ifconfig and return its output
as an array of words
:#addr:* Select the word matching addr:*
(M) Keep only the selected (`M'atching)
word, rather than deleting it
#addr: Remove leading addr: from that word
leaving just the IP address
Simple, no?
next prev parent reply other threads:[~2000-06-15 21:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-15 16:34 Shao Zhang
2000-06-15 21:42 ` Bart Schaefer [this message]
2000-06-21 15:51 ` Shao Zhang
2000-06-21 16:12 ` Shao Zhang
2000-06-21 16:39 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.20.0006151411040.23750-100000@aztec.zanshin.com \
--to=schaefer@brasslantern.com \
--cc=shao@linux.cia.com.au \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).