Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Assign each concurrent Zsh session and ID and a codename
- X-seq: zsh-users 23394
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Assign each concurrent Zsh session and ID and a codename
- Date: Sun, 13 May 2018 13:31:28 +0200
- 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==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author