twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.63k stars 475 forks source link

Long terminal prompts are cut off instead of wrapping #3583

Open detly opened 6 months ago

detly commented 6 months ago

Describe the bug

Long prompts eg. for removing or overwriting files, are cut off at the right side in the terminal. This makes it impossible to (a) see what the options are and (b) see what they're for.

To reproduce

  1. Add some files with relatively long paths
  2. Maybe resize your terminal to be a bit narrow
  3. Use chezmoi rm to remove them

Expected behavior

I'd expect the prompt to wrap.

Output of command with the --verbose flag

It's the same with or without --verbose. I started with zsh -f to try to reduce variation a bit.

~ ⚬ zsh -f
gary% cd .config/sublime-text/Packages/User 
gary% chezmoi rm Meson.sublime-syntax       
Remove /home/jason/.config/sublime-text/Packages/User/Meson.sublime-syntax and /home/jason/.loca

That's actually it - there's no more text. Here's a screenshot:

Screenshot from 2024-02-20 16-01-45

I can't scroll that eg. by pressing , or reflow it by resizing the window. I can exit it with Q or Ctrl+C.

Output of chezmoi doctor

```console RESULT CHECK MESSAGE ok version v2.46.1, commit c65f66a5f1a990ffeb4d7e3f53320cb061f91513, built at 2024-02-11T16:33:13Z, built by goreleaser ok latest-version v2.46.1 ok os-arch linux/amd64 (Ubuntu 23.10 (Mantic Minotaur)) ok uname Linux gary 6.5.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 9 17:03:36 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux ok go-version go1.22.0 (gc) ok executable /snap/chezmoi/842/chezmoi ok upgrade-method snap-refresh ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2024-02-05T16:48:15+08:00 warning source-dir ~/.local/share/chezmoi is a git working tree (dirty) ok suspicious-entries no suspicious entries warning working-tree ~/.local/share/chezmoi is a git working tree (dirty) ok dest-dir ~ is a directory ok umask 002 ok cd-command found /usr/bin/zsh ok cd-args /usr/bin/zsh info diff-command not set ok edit-command found /snap/bin/micro ok edit-args /snap/bin/micro ok git-command found /usr/bin/git, version 2.43.2 ok merge-command found /usr/bin/vimdiff ok shell-command found /usr/bin/zsh ok shell-args /usr/bin/zsh info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.2.40 info pinentry-command not set info 1password-command op not found in $PATH ok bitwarden-command found /snap/bin/bw, version 2024.2.0 info bitwarden-secrets-command bws not found in $PATH info dashlane-command dcli not found in $PATH info doppler-command doppler not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info vlt-command vlt not found in $PATH info secret-command not set ```

Additional context

This is not a recent change, I just haven't gotten around to filing an issue until now.

Chezmoi is installed via Snap, on Ubuntu 23.10. I tried this on Bash, Dash and Zsh, all with the same results.

twpayne commented 6 months ago

Thanks for reporting this.

Under the hood, chezmoi uses BubbleTea's textinput component, which isn't aware of the terminal width. There are longstanding bugs open related to this (https://github.com/charmbracelet/bubbles/issues/291, https://github.com/charmbracelet/bubbles/issues/307). Rather than trying to fix this upstream, I'll fork a new text input component.

In the short term you can work around the problem by specifying the --no-tty flag.

twpayne commented 6 months ago

I've opened https://github.com/charmbracelet/bubbles/issues/483 to track this in charmbracelet/bubbles.