Trying to add Zsh shell (with Oh My Zsh!) to new Windows Terminal, what's the right way?

Viewed 1332

Using MSYS2 and following Zsh on Windows via MSYS2 guide I installed Zsh shell on my Windows 10 Pro workstation. I installed Oh My Zsh! too via curl and powerlevel10k theme. Now I'd like to use this shell with new Windows Terminal (Preview) so in profiles.json I added this configuration:

{
    "guid": "{00000000-0000-0000-bb55-000000000003}",
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "commandline" : "\"C:\\msys64\\usr\\bin\\zsh.exe\" -i -l",
    "historySize" : 9001,
    "icon" : "C:\\msys64\\mingw64\\share\\git\\git-for-windows.ico",
    "name" : "Oh my Zsh!",
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "startingDirectory" : "%USERPROFILE%",
    "useAcrylic" : true
}

this works roughly but the prompt is not shown correctly and, every time I start the terminal, the following error is shown:

[ERROR]: gitstatus failed to initialize.

  Your Git prompt may disappear or become slow.

  Run the following command to retry with extra diagnostics:

    GITSTATUS_LOG_LEVEL=DEBUG gitstatus_start POWERLEVEL9K

  If this command produces no output, add the following parameter to ~/.zshrc:

    GITSTATUS_LOG_LEVEL=DEBUG

  With this parameter gitstatus will print additional information on error.

If i run GITSTATUS_LOG_LEVEL=DEBUG gitstatus_start POWERLEVEL9K, I get:

[ERROR]: gitstatus failed to initialize.

  Your Git prompt may disappear or become slow.

  The content of /tmp/gitstatus.197609.3944.1583052616.xtrace.log (gitstatus_start xtrace):

    +(anon):7> ((  ! _GITSTATUS_STATE_POWERLEVEL9K  ))
    +(anon):8> [[ -r /proc/version && 'MSYS_NT-10.0-19041 version 3.0.7-338.x86_64 (Alexx@WARLOCK) (gcc version 9.1.0 (GCC) ) 2019-07-11 10:58 UTC' == *Microsoft* ]]
    +(anon):11> print -rn
    +(anon):12> zsystem flock -f lock_fd /tmp/gitstatus.197609.3944.1583052616.lock
    +(anon):13> [[ 14 == <1-> ]]
    +(anon):15> typeset -gi '_GITSTATUS_LOCK_FD_POWERLEVEL9K=lock_fd'
    +(anon):18> '(anon)' /proc/self/fd/16
    +(anon):1> typeset -gi 'GITSTATUS_DAEMON_PID_POWERLEVEL9K=4011'
    +(anon):2> sysopen -r -o cloexec -u resp_fd -- /proc/self/fd/16
    +(anon):3> [[ 18 == <1-> ]]
    +(anon):4> typeset -gi '_GITSTATUS_RESP_FD_POWERLEVEL9K=resp_fd'
    +(anon):107> typeset -gi '_GITSTATUS_STATE_POWERLEVEL9K=1'
    +(anon):110> ((  ! async  ))
    +(anon):111> ((  _GITSTATUS_CLIENT_PID_POWERLEVEL9K == sysparams[pid]  ))
    +(anon):113> local pgid
    +(anon):114> ((  0 < 20  ))
    +(anon):115> [[ -t 18 ]]
    +(anon):116> sysread -s 20 -t 5.0000000000 -i 18 'pgid[$#pgid+1]'
    +(anon):116> return
                         ^ this command failed (5)

  The content of /tmp/gitstatus.197609.3944.1583052616.daemon.log (gitstatus daemon log):

    +(anon):20> local pgid=4011
    +(anon):21> [[ 4011 == <1-> ]]
    +(anon):91> ((  lock_fd == -1  ))
    +(anon):25> trap '' PIPE
    +(anon):27> [[ -z '' ]]
    +(anon):28> local kernel
    +(anon):94> zsystem flock -- /tmp/gitstatus.197609.3944.1583052616.lock
    +(anon):29> kernel=+(anon):29> uname -s
    +(anon):29> kernel=msys_nt-10.0-19041
    +(anon):30> [[ -n msys_nt-10.0-19041 ]]
    +(anon):33> [[ '' == /* ]]
    +(anon):35> ((  0  ))
    +(anon):37> [[ -n '' ]]
    +(anon):40> local os
    +(anon):41> case msys_nt-10.0-19041 (linux)
    +(anon):41> case msys_nt-10.0-19041 (cygwin_nt-*)
    +(anon):41> case msys_nt-10.0-19041 (mingw | msys)
    +(anon):41> case msys_nt-10.0-19041 (*)
    +(anon):49> os=msys_nt-10.0-19041
    +(anon):51> local arch
    +(anon):52> arch=+(anon):52> uname -m
    +(anon):52> arch=x86_64
    +(anon):53> [[ -n x86_64 ]]
    +(anon):54> local daemons=( /c/Users/icolumbro/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/usrbin/gitstatusd-msys_nt-10.0-19041-x86_64 /c/Users/icolumbro/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/usrbin/gitstatusd-msys_nt-10.0-19041-x86_64-static /c/Users/icolumbro/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/bin/gitstatusd-msys_nt-10.0-19041-x86_64 /c/Users/icolumbro/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/bin/gitstatusd-msys_nt-10.0-19041-x86_64-static )
    +(anon):57> daemons=( )
    +(anon):58> daemons=( )
    +(anon):59> ((  0  ))
    +(anon):59> return
    +(anon):86> local -i ret=1
    +(anon):87> kill -- -4011

  Your system information:

    zsh:      5.8
    uname -a: MSYS_NT-10.0-19041 z800 3.0.7-338.x86_64 2019-07-11 10:58 UTC x86_64 Msys

  If you need help, open an issue and attach this whole error message to it:

    https://github.com/romkatv/gitstatus/issues/new

Can you help me to configure Windows Terminal to use Oh My Zsh! with powerlevel10k theme correctly, please?

1 Answers

zsh-prompt

I have Zsh installed on Windows natively based on MSYS2 too. It's not on the Virtual Machine guest nor the Windows Subsystem for Linux. So you can have the best performance with the Linux shell on Windows, native compilers for Windows, tight engagement with the OS, and many other benefits.

The steps of setting up the environment are documented on the README of my dotfiles. I'm not going to copy the steps here as the paragraph is long and I don't want to go through it again just for converting the format for Stack Overflow. Please follow the section prerequisite for Windows and installation. I'm sure you can set it up properly on your machine as I built this document on Windows 10 and just tested it on a fresh installed Windows 11.

Related