From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31434 invoked from network); 14 Dec 2020 14:58:05 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Dec 2020 14:58:05 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1607957885; b=v+d6EwCB/NoJtFGm4D02porSbYSxMLyLV2IRE8zqHRqvz5Jp7UkhYoaeFkJdsDJwvwzt5fXc5J VP7e/600gs5ubIPjwG5qyBQ2uY1mrFXqIE+aTYkedMYREWzC7WpP1a+OvG0C+wi+WtE0ah6UpL yDCYX65kOpaLcRNWP3Cl+XBcozldzQKxOmvzgLrnr8RkUEHY7JZTVQo9xnQrfrY6oFa7/oJDPD UVrg7T028jSQhi5ePCxtcCtsfHcItrr+zjXxs1Elp1fdqAEJkb9ccaBYoD34M0fXPzRaRf9rAB nOiPQrnT6gHwEx3nixLrrAL7AXz5oBDpPSgd+dblyj5Www==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f54.google.com) smtp.remote-ip=209.85.166.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1607957885; bh=aJckKfFKBlxW8/z42/ElN8H7+zRmCm8MOxulqCYcoY8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=r/glKs8ddh9QZXqi+efJ8qxbXnaroeDW1tCYScKiRMUtMdW9VpM69JpB1Np75+pEfgyLCV23rU w4yzrykZZT1L9NnxrbcoL9PJEQpaoaEDSS5SyCNrI2mxF0npEAYUP1z6rJhQwyReDYZwUH+mf3 5ojefyjpRztZ4a57JLAohgYTI7x3JCXfBD84qJouLB+w3W/xyAn/I52dNATcVccW60zelMkHLk uYFkfc9un/MBxELD0kLKP0uCxRY1L4OM3iA0x9pMxMwo4d7mYL6avBVvjzvF5CdTP3j6S2fEW+ F7zfAsBAbbmpXO8Nhse6hVYOAQJYn+kZqGEK3eFtGI1/5g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=vF9Ofoar6/D/IET57Gv13cFVTYutKnEjb6+g+CEd9nE=; b=k4rTRSmf3mqm9n/dyuTZUcu7Xm tXWZCbVgmEUvvHKL3sBzI82vOSQb6z1pyBl+zSnEvVa8etENvhfO1Vxh/pgC8OD39cLozmKfvOrb4 c2Fat2mguRqPqcHyiknPiuO13JBOeLMKZvsgT+jT8e9JgbL7zYpGAqT2s6YPTTjrPZadghw/4yONg ol18NTWiGYO8hPDDNArcj6OW1p5TO6Qmwi/FqlyxJYKXyhW468NxUvPRcoa32siOnlVMpf1NPci6p NI4Bbf0gvgIHbk/O+mKZdipsSO/8OauGwiIgwBhk454ECJbUJfUFjZM5twodyyhvZiwJHQkZUGF/7 vuSLUvig==; Received: from authenticated user by zero.zsh.org with local id 1kopIZ-0009mf-J4; Mon, 14 Dec 2020 14:58:03 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f54.google.com) smtp.remote-ip=209.85.166.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f54.google.com ([209.85.166.54]:46614) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kopI5-0009QO-Fd; Mon, 14 Dec 2020 14:57:34 +0000 Received: by mail-io1-f54.google.com with SMTP id 81so17068239ioc.13 for ; Mon, 14 Dec 2020 06:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vF9Ofoar6/D/IET57Gv13cFVTYutKnEjb6+g+CEd9nE=; b=KAfKOSoNY9X4jItqsXN2EgumhEk2MQU16aNknk6c4rYGhHjDDfJYEwJlKM3hbegHND nCAWj2RndTMS4zxkh5j/n2hsG1E+OFqv2jmIMRcaF9Ool3EPM3wXfmX73HqQr5488Tp5 xVMoQX/hekYVSAcRlEHDdpqRgS+aBQvJlwB2y1iie1mdfuRxYZIgtmC7LjMqMtBsvUY3 uaX4L/wTztORGp9CUMlCQ39N5L3Ts/okp7qy2vOKu9VcxmMjqh2QcE9ZJTmscyhxKt/m m50sW5Q9XlLzrGHjwJasNiirdyMwz+GUIAEQiiYNwoWF2dBfw6KCR+AjTe23x28lzxZk W4OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=vF9Ofoar6/D/IET57Gv13cFVTYutKnEjb6+g+CEd9nE=; b=Cz9qwd3eAdU3zoqGKqz2bGN9jfJKSyYvRL1nF1kADnzDlkKQNEVEMEKxB4njl7Lnke dgfiE0W2n9gBVYMcrOFJ45wra+iRouH3TLtFdI3OBowiQRQlE7EdusqfyvH4IOg5Nd+e mEPldjd9bD1FZ7A/PMF/ROG89Lsbf8h/VGK3r6jBK6f/+gqZAsNU3ogc8HmCH+ShMLlk Taj/0MSsBzoqBgo4nW3FGNlwR6c/f0Pd5/0KO8ctUQQZxnq/LLyJEh30nWwvm9irUoon qHkdsOu+hGGaPPfe6lzklE0Euw22Qh6x/0QgDLfBINHkXBkDb/H7mVpnZfuHs2ZuBYA0 zoYQ== X-Gm-Message-State: AOAM532Akr5v8980cItbcBJbQyVWrxe/rA5wEkXO7ftgNRXP0sJ+vWpW vReOudK7WkvGDaxvMBautNJJN+ES0YDXabkPSg8= X-Google-Smtp-Source: ABdhPJywg7GWBcFZeUze2YM+sQ6sshHaV9dlTqCVJwSzbHrz8k2VN3Z2QBlIlW4yyqfDcGhUXtBNtH0CDB2hlqa+wYs= X-Received: by 2002:a5e:d510:: with SMTP id e16mr33112460iom.21.1607957851847; Mon, 14 Dec 2020 06:57:31 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a4f:ac4a:0:0:0:0:0 with HTTP; Mon, 14 Dec 2020 06:57:30 -0800 (PST) In-Reply-To: References: From: Mikael Magnusson Date: Mon, 14 Dec 2020 15:57:30 +0100 Message-ID: Subject: Re: Call a function when idle? To: "A. Wik" Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 26225 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On 12/14/20, A. Wik wrote: > Hi all, > > For the most part, when I get started working at a terminal, I can do > just fine with a simple and short prompt like "% ". A prompt that > includes the current directory often gets annoyingly long so that you > can rarely type a command line that doesn't scroll onto another line, > which is harder to read. > > However, when I've been away from a terminal (window or tab) for some > time, I would like to know where in the file system I am, to remind me > (hopefully) of what I was doing. If the current working directory is > not in the prompt, I have to type "pwd" manually. > > To solve the problem, I was thinking of getting a function to run > after a specified period of idle time. This function could then run > "print -P" to print useful pieces of data, such as the hostname, the > tty name, etc., and of course the current directory. > > So, the question is how to set up an idle timer to call the function. > I figured someone had already done something like that before (perhaps > to log out automatically). TMOUT If this parameter is nonzero, the shell will receive an ALRM signal if a command is not entered within the specified number of seconds after issuing a prompt. If there is a trap on SIGALRM, it will be executed and a new alarm is scheduled using the value of the TMOUT parameter after executing the trap. If no trap is set, and the idle time of the terminal is not less than the value of the TMOUT parameter, zsh terminates. Other=E2= =80=90 wise a new alarm is scheduled to TMOUT seconds after the last keypress. You may want to unset TMOUT in your handler and then arrange for it to be set when you enter a new command line and/or any relevant information has changed, otherwise you will come back to a lot of the same information. And/or use zle -M to print the information, it will be printed below the prompt (replacing any previous such message), it will then be lost when overwritten by further commands/prompts. eg, zle -N zle-line-init _zle_line_init function _zle_line_init() { TMOUT=3D3 } TMOUT=3D3 TRAPALRM() { zle -M "hi there, you're in $PWD"; unset TMOUT } --=20 Mikael Magnusson