zsh-users
 help / color / mirror / code / Atom feed
* Assign each concurrent Zsh session and ID and a codename
@ 2018-05-13 11:31 Sebastian Gniazdowski
  0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2018-05-13 11:31 UTC (permalink / raw)
  To: Zsh Users

[-- 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-13 11:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13 11:31 Assign each concurrent Zsh session and ID and a codename Sebastian Gniazdowski

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).