From: Marc Chantreux <eiro@phear.org>
To: Anthony Fletcher <anthony@bifb.org>
Cc: zsh-users@zsh.org
Subject: Re: autoload variables
Date: Tue, 31 Aug 2021 22:37:55 +0200 [thread overview]
Message-ID: <YS6TI9eVkktkyvfJ@prometheus.u-strasbg.fr> (raw)
In-Reply-To: <CAPT4cGdBZQDQv8ozkpgYwzm60yqmpJwCKCSPUnLaAj-Rp+F6kg@mail.gmail.com>
hello zsh users,
> We can autoload functions but is there a way to autoload variables?
i was hoping for a better answer than mine (reading this list provides
me so many "wow" moments). the way i dealt years ago to deal with my
"too heavy .zshenv" is to write what i call "modules"
<<\. cat > /usr/local/bin/mynetstuff.zsh
# yes i use setopt pathdirs :)
export IFUP=$( ip -4 r |sed ...)
mynetstuff/thing () { ... }
mynetstuff/stuff () { ... }
.
now i can run
. mynetstuff.zsh
when i need my net stuff. to unload functions, you can write
unset 'functions['$^functions[(I)mynetstuff/*]']'
oth.
besides: if the sed command is for real, i'm curious about
how it works:
sed -n -e '/^default/ s/^default.*dev //; s/ > .*// p;q'
my guess is it is equivalent to
sed -r '/^default dev (\S+) .*/!d; s//\1/; q'
or
ip -4 r | sed -r '/^default dev /!d; s///; s/ .*//; q'
but as you quit anyway, i assume you *know* that what you need is on the
first line so this should do the job:
ip -4 r | head -n1 | cut -d' ' -f3
regards,
marc
next prev parent reply other threads:[~2021-08-31 20:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 15:22 Anthony Fletcher
2021-08-30 15:41 ` Roman Perepelitsa
2021-08-30 16:40 ` René Neumann
2021-08-30 16:57 ` Anthony Fletcher
2021-08-30 19:30 ` Mikael Magnusson
2021-08-30 21:34 ` René Neumann
2021-08-30 21:46 ` Bart Schaefer
2021-08-31 0:10 ` Anthony Fletcher
2021-08-31 18:11 ` Roman Perepelitsa
2021-08-31 19:16 ` Bart Schaefer
2021-08-30 16:49 ` Bart Schaefer
2021-08-31 20:37 ` Marc Chantreux [this message]
2021-08-31 21:03 ` Roman Perepelitsa
2021-09-01 8:29 ` Marc Chantreux
2021-09-01 9:51 ` Roman Perepelitsa
2021-09-01 10:06 ` Marc Chantreux
2021-09-01 13:52 ` Bart Schaefer
2021-09-02 23:09 ` Anthony Fletcher
2021-09-03 0:07 ` Bart Schaefer
2021-09-03 6:52 ` Marc Chantreux
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=YS6TI9eVkktkyvfJ@prometheus.u-strasbg.fr \
--to=eiro@phear.org \
--cc=anthony@bifb.org \
--cc=zsh-users@zsh.org \
/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).