ChrisJohnsen / tmux-MacOSX-pasteboard

Notes and workarounds for accessing the Mac OS X pasteboard in tmux sessions. Note: The pu branch (“Proposed Updates”) may be rewound without notice.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.zshenv loading twice

artemave opened this issue · comments

set-option -g default-command "reattach-to-user-namespace -l zsh" causes .zshenv to load twice. That slows down terminal startup.

So instead I aliased vim to reattach-to-user-namespace vim and set up tmux <-> sytem copy/paste integration as per here: http://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future

That is a fine way to go, it is just a more complex setup than I wanted to describe in the README.

It took me some time to figure out why my terminal start up time was slow. If your README mentioned the fact that .zshenv loads twice (since it starts up shell inside shell), that journey could have been shorter. That is all.

You probably have default-shell set to a zsh (it gets its default value from SHELL or your login shell). tmux uses default-shell to run the default-command; this is where the extra instance of zsh comes from.

With default-shell set to a zsh, and a default-command that runs zsh, .zshenv will run twice (once for the default-shell instance, once more by the default-command), but the other files (.zprofile, .zshrc, and .zlogin) will only run once (by the shell started by the default-command).

If you set default-shell to something else (e.g. /bin/sh), then it should avoid that first instance of zsh. But, tmux will also set SHELL to the value of default-shell, so if you want SHELL to be zsh, then you may want to change it in one of your zsh initialization files.


But, since .zshenv is run for all instances of zsh (unless -f is given or NO_RCS is set), you might want to rearrange your initialization code so that .zshenv does not do as much (maybe move some of it to the other initialization files).