Closed kamusis closed 2 years ago
Thank you @romkatv for point out the right answer of this issue. Now I know it's not the power10k issue, but it will be very appreciated if you can let me know Is there a way to change iTerm2 or ZSH (I don't know which one handle this) to truncate strategy when handle long lines.
Zsh cannot truncate on resize, only a terminal can. I don't know whether iTerm has an option for this.
FWIW, see this iTerm2 issue; it's over six years old and "very complicated" according to iTerm2's author.
I did some search on google, someone point out the "tput rmam" will disable line wrap in terminal. This one: https://egghead.io/lessons/bash-disable-line-wrapping-in-osx-or-linux-terminal and this one: https://stackoverflow.com/questions/28954083/how-to-turn-off-word-wrap-in-iterm2 I tried, but still has no effect. no matter in iTerm2 or the native Terminal app. I'm now confused if the "truncate strategy" equal "disable line wrap"?
No, that's different. rmam controls wrapping when the data is written. There is no termcap or terminfo capability to control wrapping when the terminal is resized.
Wrapping long lines is a side effect of resizing an iTerm2 window to a narrower width.
The alternative to wrapping is to either:
1) keep the long lines, and make the extra data accessible via a horizontal scrollbar 2) truncate any lines that are now too long and throw away the data that doesn't fit
Neither of these alternatives are available in iTerm2. The feature request I linked to is to add option 1.
@romkatv @eddyg ok... so let's forget about iTerm, maybe you know which terminal app has "truncate strategy" option, in macOS or in Linux, I can try it to figure out what is like.
xterm truncates on resize.
xterm truncates on resize.
Oh, no... you mean I have to install XQuartz, makes me feel like using an old computer 20 years ago :sweat_smile: In the thread that @eddyg mentioned, I found someone said all Terminal-like apps in macOS lack this option.
Really? even after 6 years, still no native app fix this issue? maybe is really "very complicated".
Have you read through issue #175 ?
Roman tried to improve the situation with an upstream patch to zsh
but it was (unfortunately!) "ignored". 😞
Really? even after 6 years, still no native app fix this issue?
That's not entirely correct. I believe this should work:
~/.zshrc
:
unset KITTY_SHELL_INTEGRATION
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
(
emulate -L zsh -o err_return
git clone https://github.com/kovidgoyal/kitty && cd kitty
brew install harfbuzz zlib libpng pkg-config little-cms2 librsync
export LDFLAGS='-L/opt/homebrew/lib'
export CFLAGS='-I/opt/homebrew/include'
make -j 8
)
~/kitty/kitty/launcher/kitty
.Now, when you shrink the terminal window, everything should be wrapped except the last prompt. This way you won't lose any data (as you would if your terminal truncated all lines) and you won't have a mess (as you would if your terminal wrapped all lines).
Kitty is one of the best terminals for macOS, so you might want to give it a try anyway.
Kitty is one of the best terminals for macOS, so you might want to give it a try anyway.
I just used "brew install --cask kitty", not sure is there any difference with your "install kitty from master" commands. then I modified the .zshrc as you said, added 2 lines
unset KITTY_SHELL_INTEGRATION
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
then opened kitty, resize the window several times... looks like the issue is still there.
I just used "brew install --cask kitty"
You've installed the latest released version. It doesn't have the fix.
FYI: I've implemented in zsh4humans the same resizing logic as has been previously implemented only in Kitty. I don't know how to fix the horrific mess for all powerlevel10k users but at least it's now a solved problem for those that use zsh4humans. If you are already using zsh4humans, see https://github.com/romkatv/zsh4humans/issues/35#issuecomment-996893347 for details. If you aren't using zsh4humans, and the mess on resizing is really bothering you, consider trying zsh4humans. The new resizing logic is enabled by default if you choose "No" when asked by the installer whether you want zsh to always run in tmux.
but at least it's now a solved problem for those that use zsh4humans.
Yes! you did it. I tried z4h, it works! Thank you for the effort.
After install z4h, I found $ZSH_CUSTOM was changed.
❯ echo $ZSH_CUSTOM
/Users/kamus/.cache/zsh4humans/v5/ohmyzsh/ohmyzsh/custom
This makes some plugins that were originally located at ~/.oh-my-zsh/custom/plugins cannot be found, it's not a big deal. but it makes me think what is the method that z4h works with oh-my-zsh?should I "source $ZSH/oh-my-zsh.sh" or not? If I want to add some plugins manually, what is the best practice (add them to .oh-my-zsh or add them to .cache/zsh4humans/v5/ohmyzsh)?
To use a third-party plugin with zsh4humans you need to make two changes to ~/.zshrc
. For the sake of example, let's assume you want to use https://github.com/romkatv/zsh-prompt-benchmark (you shouldn't actually use it):
z4h install
in ~/.zshrc
and append an extra argument to it: z4h install ... romkatv/zsh-prompt-benchmark
. Alternatively, add a new line: z4h install romkatv/zsh-prompt-benchmark || return
z4h load
in ~/.zshrc
and append an extra argument to it: z4h load ... romkatv/zsh-prompt-benchmark
. Alternatively, add a new line: z4h load romkatv/zsh-prompt-benchmark
Restart zsh with exec zsh
for the changes to have effect.
If you want to use a branch other than master
, pass the name of the branch to z4h install
like so: romkatv/zsh-prompt-benchmark@somebranch
.
If you want to use plugins from ohmyzsh, search for z4h load
in ~/.zshrc
to see an example.
Note that there are very few plugins that do anything useful on top of zsh4humans. Almost everything of value is already backed in, although sometimes you'll need to enable and/or configure it. E.g., see this for a built-in alternative to z
, autojump
, etc.
If you want to use plugins from ohmyzsh, search for
z4h load
in~/.zshrc
to see an example.
It's cool! Now everything looks perfect. A little suggestion, "alias tree='tree -a -I .git -N'" should be better, -N will print out words other than English.
Have a good day, Roman. Thank you for all the replies and all the works.
A little suggestion, "alias tree='tree -a -I .git -N'" should be better,
I'd rather not. Try this:
touch $'\e7\e[H\e[41m\e[J\e8test'
Then try tree
with -N
and without.
For me, not having the connecting line between (Left and Right prompt) almost stops the issue.
And having this on .zshrc
function p10k-on-post-prompt() {}
TLDR config file added!
@sagarkar10 That sounds rather unlikely. Try pressing Ctrl-C and then resizing your terminal. It'll get messed up. You can also try entering a very long command and resizing your terminal. It'll also get messed up. If this is surprising to you, read the docs and what I already posted here.
Please see the screenshot.
Can be easily reproduced by split pane in ITerm2 and then try to resize the pane by dragging the split line.