From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17215 invoked by alias); 13 May 2018 11:31:54 -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: List-Unsubscribe: X-Seq: 23394 Received: (qmail 28543 invoked by uid 1010); 13 May 2018 11:31:54 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot0-f171.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.171):SA:0(-1.9/5.0):. Processed in 1.725142 secs); 13 May 2018 11:31:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=qTHnuP+jFdmsDZugC1h1idJM5FK0PwqVhyJoHNVGMqw=; b=CRAZg5GeWRSNGB6/xX5vOr5ocPM/mJ82xTMvTPWBQ7l6pj+1KXyzJ9kqZiagN0FfN4 moPjgh3zIFWU/PkUEOptNsLm/yhcEVbjM9FgDb+vlGPMGX2LU76gT5q3W9PceJVweK7d VdUZ4WSKkZdNyOd0MvAihC0y2+N8VCyB5U/wKnIwA0AAomPjck7TL9rpX8YvUlcuN2w6 AU3aFtTHOnXcrzCa/sG7IR5o12D1QcYPerDfiadedZh1JTKF9pUAdcS4zb89Av5DGmjL XQZucTwlbc0JLIhSnJbRIsCKb5fueBTnP9WiOi/uXVISUF7+WK45lMeFGjCLGwwDWN8f qMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=qTHnuP+jFdmsDZugC1h1idJM5FK0PwqVhyJoHNVGMqw=; b=fzT709YNeWENRG60VhfXKCPJFto5cBxyaoBbw7WO8VmWZwX3V1hwwMtTl3c3wzizkW ZSW8+dLCxC7bpV5ZRvL8Bg26uRY2wsUeM5J//r5TZkWj3UmfLY+Qe+znlgz5M0NyvouS pDiRefL7qb0E7NtVrg5RwdN3Wu0AxnerZAA6G8hbpbko8sfCqg/sYNS/4L7yPfXZ4uTS HXtUE81D4atIJxL5rhX14il9tC5xTAp8umXJePzkmcCbAFON7hWWYIi9PhF024C3Eu0/ NuvaSzRBegnr+fK+tLoCT9na6ELLGwshri1kyvdw82Iu/y0PFedlrDs11EItrNZ+1aK3 GWKw== X-Gm-Message-State: ALKqPwdO67nc11N+VEVqu7cMDpXHf8kZjnYfvKyFH6Pbz3YxBzVewfA1 St/5ycYuectEws62K7uXG/whpp2JhHfbECKWtB6bow== X-Google-Smtp-Source: AB8JxZqpt7u4RDBBo64YTiVBxqMawG5VpN5qQ5SZ7yfeooUtkYSZ1Fwug+eN7p7nLH019RW8V/xvWWe6rHPUygtZMbk= X-Received: by 2002:a9d:59e3:: with SMTP id u35-v6mr4392591otg.287.1526211109539; Sun, 13 May 2018 04:31:49 -0700 (PDT) MIME-Version: 1.0 From: Sebastian Gniazdowski Date: Sun, 13 May 2018 13:31:28 +0200 Message-ID: Subject: Assign each concurrent Zsh session and ID and a codename To: Zsh Users Content-Type: multipart/alternative; boundary="0000000000000955f7056c14b758" --0000000000000955f7056c14b758 Content-Type: text/plain; charset="UTF-8" Hello Typical solution for granting each Zshell a separate file is to use $$, e.g.: LOGFILE=$HOME/.cache/zsh-logs/zsh.$$.log. This means there will be enormous number of files created. The plugin zdharma/zsh-unique-id allows to set: LOGFILE=$HOME/.cache/zsh-logs/zsh.${ZUID_CODENAME}.log No two concurrent Zsh sessions will have the same code-name. $ZUID_ID can be used to have numbers 1, 2, ... instead of code-names. Could be an upstream autoload function a good idea for this? autoload -Uz acquire-unique-id acquire-unique-id # sets ZSH_UID and ZSH_UID_CODENAME The code is simple, it uses zsystem-flock (util-linux/flock for Zsh < 5.3, but that doesn't matter for upstream), it's the second link. Plugin is at: https://github.com/zdharma/zsh-unique-id Business logic code: https://github.com/zdharma/zsh-unique-id/blob/master/zsh-unique-id.plugin.zsh#L76-L156 -- Best regards, Sebastian Gniazdowski --0000000000000955f7056c14b758--