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