0

I started XTerm today and for some reason ZSH is printing what looks like env when my shell starts up. I am just wondering if there is a way to track down what is doing this so I can disable it. Below is the output when the shells starts

Last login: Wed Jul 11 19:22:03 on ttys000
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.G1oq8Ke9bW/Render
COLORFGBG='7;0'
COLORTERM=truecolor
DISPLAY=/private/tmp/com.apple.launchd.tY95B5y3iQ/org.macosforge.xquartz:0
GPG_TTY=/dev/ttys000
HOME=/Users/joshuastroup
ITERM_PROFILE=Default
ITERM_SESSION_ID=w0t0p0:AF741932-F358-4C2C-9A23-47134F004CE3
LANG=en_US.UTF-8
LOGNAME=joshuastroup
OLDPWD=/Users/joshuastroup
PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/joshuastroup/.nvm/versions/node/v8.9.3/bin:/usr/local/Cellar/php/7.2.6/bin:/Users/joshuastroup/bin:/Users/joshuastroup/binaries'
PWD=/Users/joshuastroup
SHELL=/bin/zsh
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.8a9z6UEe0q/Listeners
TERM=xterm-256color
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.1.7
TERM_SESSION_ID=w0t0p0:AF741932-F358-4C2C-9A23-47134F004CE3
TMPDIR=/var/folders/75/kd4myl4s32l596p9fqhxv_pr0000gn/T/
USER=joshuastroup
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
__CF_USER_TEXT_ENCODING=0x0:0:0

And below is the output of env

[~] env                                                                                                                 19:23:54
TERM_SESSION_ID=w0t0p0:AF741932-F358-4C2C-9A23-47134F004CE3
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.8a9z6UEe0q/Listeners
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.G1oq8Ke9bW/Render
COLORFGBG=7;0
ITERM_PROFILE=Default
XPC_FLAGS=0x0
LANG=en_US.UTF-8
PWD=/Users/joshuastroup
SHELL=/bin/zsh
TERM_PROGRAM_VERSION=3.1.7
TERM_PROGRAM=iTerm.app
PATH=/usr/local/Cellar/php/7.2.6/bin:/Users/joshuastroup/bin:/usr/local/bin:/Users/joshuastroup/binaries:/usr/local/opt/go/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/joshuastroup/.nvm/versions/node/v8.9.3/bin:/usr/local/Cellar/php/7.2.6/bin:/Users/joshuastroup/bin:/Users/joshuastroup/binaries
DISPLAY=/private/tmp/com.apple.launchd.tY95B5y3iQ/org.macosforge.xquartz:0
COLORTERM=truecolor
TERM=xterm-256color
HOME=/Users/joshuastroup
TMPDIR=/var/folders/75/kd4myl4s32l596p9fqhxv_pr0000gn/T/
USER=joshuastroup
XPC_SERVICE_NAME=0
LOGNAME=joshuastroup
__CF_USER_TEXT_ENCODING=0x0:0:0
ITERM_SESSION_ID=w0t0p0:AF741932-F358-4C2C-9A23-47134F004CE3
SHLVL=1
OLDPWD=/Users/joshuastroup
GPG_TTY=/dev/ttys000
ZSH=/Users/joshuastroup/.oh-my-zsh
PAGER=less
LESS=-R
LC_CTYPE=en_US.UTF-8
LSCOLORS=Gxfxcxdxbxegedabagacad
NVM_DIR=/Users/joshuastroup/.nvm
NVM_CD_FLAGS=-q
NVM_BIN=/Users/joshuastroup/.nvm/versions/node/v8.9.3/bin
_=/usr/bin/env
  • What are the results of- grep 'env' ./.z* ? – fd0 Jul 12 '18 at 0:23
  • pastebin.com/wU5tJ0s0 – Wargog Jul 12 '18 at 18:46
  • Thanks, I'm not seeing anything. iTerm start a login shell and xterm starts a non-login interactive shell. Each session read different config files- xterm would read /private/zshenv if it exists, then .zshenv (if it exists) and then zshrc. I'd start there with your trouble shooting. You might start first removing by oh-my-zsh from the mix. – fd0 Jul 12 '18 at 18:59
1

In order to track this down, you can start zsh with the option -x. (You can just run this from your current shell session). This will add debug output for each line of shell code that is run. The output will be formated like this

+FILE_OR_FUNCTION:LINE_NO> COMMAND_LINE

For example, should the output be generated by an env command on line 7 of ~/.zshrc the output might look something like this:

% zsh -x
[…]
+/Users/joshuastroup/.zshrc:6> print_lastlog
Last login: Wed Jul 11 19:22:03 on ttys000
+/Users/joshuastroup/.zshrc:7> env
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.G1oq8Ke9bW/Render
COLORFGBG='7;0'
COLORTERM=truecolor
DISPLAY=/private/tmp/com.apple.launchd.tY95B5y3iQ/org.macosforge.xquartz:0
GPG_TTY=/dev/ttys000
[…]

Depending on your shell configuration this might generate a lot of output. You might need to increase the scrollback buffer, if you cannot view everything in your terminal.

1

I suggest you gather some more information. For each of the login scripts (/etc/zshenv, /etc/zprofile, /etc/zshrc, /etc/zlogin, .zshenv, .zprofile, .zshrc, .zlogin), add a line at the beginning that prints to stdout something like ".zshenv starts" and a line at the end like ".zshenv ends". Once you figure out which script is responsible, scatter some print statements to pin down the exact command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .