From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27436 invoked by alias); 7 Feb 2014 11:54:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18414 Received: (qmail 26782 invoked from network); 7 Feb 2014 11:54:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Thorsten Kampe Subject: Re: Executing command on reattaching to screen session Date: Fri, 7 Feb 2014 12:54:15 +0100 Message-ID: References: <140206200141.ZM27955@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p579b24d0.dip0.t-ipconnect.de User-Agent: MicroPlanet-Gravity/3.0.4 * Bart Schaefer (Thu, 06 Feb 2014 20:01:41 -0800) > On Feb 6, 7:27pm, Thorsten Kampe wrote: > } Every time I login, /etc/motd is displayed. Since I hardly ever > } log out and in, I'd like to have the same functionality when > } reattaching > > Perhaps a better way to do this is to put something in your precmd > hooks so that the /etc/motd is shown when it has changed? E.g., > > latest_motd() { > if [[ /etc/motd -nt ~/.last_motd ]] > then > cp --preserve=timestamps /etc/motd ~/.last_motd > cat ~/.last_motd > fi > } > add-zsh-hook precmd latest_motd Thanks for the suggestion. The information has to be displayed regularly even if it hasn't changed. I was unsure whether to handle the task on the terminal (multiplexer) or on the shell level. As far as I can see, the shell doesn't get "notified" when I reattach, so it has to be done on the screen/tmux level. The best "approximation" I found so far is to display not on reattaching but on idle: I changed the byobu backend to screen, then I created a .screenrc in ~/.byobu containing blankerprg zsh -c "while true; do cat /etc/motd.d; sleep 30; clear; done" idle 600 That uses screen's screensaver functionality to display text I would normally only see on login on a blank screen. Thorsten