zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Assign each concurrent Zsh session and ID and a codename
Date: Sun, 13 May 2018 13:31:28 +0200	[thread overview]
Message-ID: <CAKc7PVBA7hJNgyh8qjDyoP-7icenkRbmizQaETscU8hTS1Jedw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

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

                 reply	other threads:[~2018-05-13 11:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVBA7hJNgyh8qjDyoP-7icenkRbmizQaETscU8hTS1Jedw@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).