Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Watcher script - please comment
- X-seq: zsh-users 15052
- From: Matt Wright <matt@xxxxxxxxxxxx>
- To: jarausch@xxxxxxxxxxxxxxxxxxx
- Subject: Re: Watcher script - please comment
- Date: Wed, 5 May 2010 08:27:36 -0700
- Cc: zsh-users@xxxxxxx
- In-reply-to: <tkrat.d90ba1177c225a6b@xxxxxxxxxxxxxxxxxxx>
- 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: <tkrat.d90ba1177c225a6b@xxxxxxxxxxxxxxxxxxx>
I know it's dirty but I use this to check if my dotfiles git repository has new updates available. I wonder if you could adapt that.
#!/bin/zsh
# register a SIGUSR1 handler, this will let us catch a message from
# the spawned subshell below.
TRAPUSR1() {
[[ -o zle ]] && zle -I
echo "NOTE: A dotfiles update is available in git."
# reset trap USR1 so we're not hogging it
trap - USR1
}
# grab the current PID so we can signal ourselves, the &| at the end of the
# brackets cause us to disown the child so they don't print on our window.
PID=$$
(
cd ~/.dotfiles
# make sure we never ask for a password with this check
export GIT_SSH="${HOME}/.dotfiles/tools/quiet-ssh.sh"
l=$(git rev-list master | head -1)
r=$(git ls-remote origin heads/master | awk '{print $1}')
if [[ "${r}" != "$(git merge-base ${r} ${l} 2>/dev/null)" ]]; then
# signal ourselves to write on the terminal
kill -USR1 $PID
fi
) 2>/dev/null &|
On May 5, 2010, at 4:25 AM, Helmut Jarausch wrote:
> Hi,
>
> I'd like to start a "daemon" which notifies me if some file
> is no longer accessed (e.g. by rsync from a remote host).
>
> My simple minded solution is
>
> #!/bin/zsh
>
> while /bin/true; do
> if ! fuser -s $1; then break; fi
> sleep 5
> done
> notifier -1 -e5 -tREADY <<< $1
>
>
> where the file in question is passed as a parameter.
>
> Is there something builtin into ZSH which is more efficient / elegant.
>
> Many thanks for a hint,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
Messages sorted by:
Reverse Date,
Date,
Thread,
Author