Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: re-source rc atomically
- X-seq: zsh-users 18987
- From: shawn wilson <ag4ve.us@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: re-source rc atomically
- Date: Wed, 23 Jul 2014 09:56:29 -0400
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=guKpZZgJmvPhyfKmaOKOCxODguRXvOn1eAc/VJQVfrA=; b=HWBiSHFSoWOmbem9ECnMJqngKNlrR2Mh+NT0wHP9xAnNdcbisVdUCR76+gO8gyfjhm xjb4GVj75GMxiv71KnYEqnfmet5vQHYclOl8//leWPr00QjjcHrZD8NHSNoY0xG1eus9 2hESiOfamUbqMxfqGWaZSbQQ3vZ1O3l5jDMt3gUu6i71HY2gHpOnAIbDhS4qPuSN3s30 6HstM6MkpmIMxU4MbdCS7NGBNB3hpFdFu7NwPx/Mo2W1Tuw56ALvCo/gvJpsamKI7SKI vUYLXxDq6rvANblyX+V2K2GWsREX9hzqqmmUfo6irs0TQgFz/v8/7DUvOxcRKyAnHQ6Z HsHw==
- In-reply-to: <20140723135612.6c08753d@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAH_OBid4iySweF05Y9bsauVsM5O4ZQv4ie3_M7L9HXnxqRLfBw@mail.gmail.com> <20140723135612.6c08753d@pwslap01u.europe.root.pri>
Second time in a row precmd is a big part of the solution to my
problem - maybe I'll remember this next time :)
Thanks
On Wed, Jul 23, 2014 at 8:56 AM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 23 Jul 2014 08:02:27 -0400
> shawn wilson <ag4ve.us@xxxxxxxxx> wrote:
>> Is there a way to source my zshrc somewhat atomically?
>>
>> I wouldn't want to do this to all of my sessions in case I mess
>> something up. But it would be nice if this were re-sourced in most as
>> automatic as possible so that when I change an alias or add a new
>> function I don't have to remember what was added when and manually
>> source my config when something doesn't work as expected.
>
> I guess you know about ". ~/.zshrc" and are asking if there's a way to
> do that without you having to type it.
>
> You can do stuff like this. Use the array precmd_functions if you
> have other things in precmd.
>
> precmd() {
> local -a stat
> integer last_change
> zmodload -F zsh/stat b:zstat
> zstat -A stat +mtime ~/.zshrc
> last_change=$stat[1]
> if [[ -n $ZSHRC_LAST_CHANGE && last_change -gt ZSHRC_LAST_CHANGE ]]; then
> # We don't want this to occur in function scope.
> trap '. ~/.zshrc' EXIT
> fi
> typeset -ig ZSHRC_LAST_CHANGE
> ZSHRC_LAST_CHANGE=last_change
> }
>
>
> You'd better make sure .zshrc doesn't define a conflicting precmd(), of
> course (as mine just did...)
>
> You could loop over other functions if you wanted.
>
> pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author