romkatv / zsh4humans

A turnkey configuration for Zsh
MIT License
1.7k stars 111 forks source link

Help setting z4h together with toggleterm.nvim #288

Closed rafaelliu closed 6 months ago

rafaelliu commented 8 months ago

I'm using z4h and toggleterm.nvim (through LunarVim) but toggling the terminal imediately exits my console app (alacritty).

I'm using start-tmux (so I can get the promt at the bottom) and I've seen this before with embedded terminals in VSCode and JetBrains. It has been enough to just fallback to a non-tmux zsh in those cases:

if [ "$TERMINAL_EMULATOR" = "toggleterm" ] || "$TERMINAL_EMULATOR" = "JetBrains-JediTerm" ] || [ "$TERMINAL_EMULATOR" = "VSCode" ]; then
  zstyle ':z4h:' start-tmux no
  zstyle ':z4h:' propagate-cwd yes
else
  # Mark up shell's output with semantic information
  zstyle ':z4h:' start-tmux       command tmux -u new -A -D -t z4h
fi

But this is not enough for toggleterm for some reason. I also need to gate this line (which seems to do much of the magic):

z4h init || return

This is likely still tmux related, all the symptoms are the same: the console dies, tmux session is kept, and if I start my main session with start-tmux no togglevim works.

Any ideas of what may be going on? Any tips on further troubleshooting it?

romkatv commented 8 months ago

What happens if you remove this whole section with if-else-fi? Does the terminal work? Are you missing any functionality?

rafaelliu commented 8 months ago

Removing the if-else-fi section works. And the prompt does stay at the bottom! That will do it, I set Alacritty to start tmux and now togglevim is happilly spawing zsh. Thanks much!

Curious: how is setting "start-tmux" to "no" and removing it altogether different? Prompt doesn't stay at the bottom using "no"

romkatv commented 8 months ago

Curious: how is setting "start-tmux" to "no" and removing it altogether different? Prompt doesn't stay at the bottom using "no"

https://github.com/romkatv/zsh4humans/blob/master/tips.md#tmux

If you haven't seen this document, I highly recommend reading the whole thing and implementing as many tips as you can. The default z4h experience is gimped.