bullet-train.zsh
bullet-train.zsh copied to clipboard
Feature request: Omit the first new line
Can you make this improvement?
Delete the first new line before first prompt line
see:
I want the new line, but after of first command.
Thanks
Is this occurring only at the first line on at every prompt?
@dawikur I want the new line on every prompt, but the new line at the first prompt seem rare because it adds an unnecessary line. I know 'BULLETTRAIN_PROMPT_ADD_NEWLINE' but what I want is omit the first new line if it could
BULLETTRAIN_PROMPT_ADD_NEWLINE
option adds newline after prompt, not before; so you ffirst new line rather is not caused by it. Maybe you have something in your zshrc
file that is producing this line?
+1 on this issue. Setting BULLETTRAIN_PROMPT_ADD_NEWLINE=(false)
removes the newline from the top of the terminal but then I'm stuck with a cramped terminal after a few commands.
+1 from me as well - tried it from a new user with a bare-bones zshrc (oh-my-zsh, bullet-train + add_newline false) and the error persists. To be clear: "echo
As a workaround, you could set the theme to powerlevel9k, source oh-my-zsh, set the theme to bullet-train, and source it again. This worked for me. If sourcing oh-my-zsh twice causes other errors, set a flag after the first source and use the flag to disable all but the theme component of your oh-my-zsh script.
Edit -- this workaround isn't perfect, powerlevel9k has other effects on the prompt. I'll update if I figure anything out.
Here is my current solution: ~/.zshrc
PS1=${PS1//\n//}
SOURCED_ZSHRC=${SOURCED_ZSHRC:-0}
let "SOURCED_ZSHRC++"
export SOURCED_ZSHRC
if [ "$SOURCED_ZSHRC" -lt 2 ]; then source ~/.zshrc; fi
I'm not sure why I need to source it twice; for the root instance, once is enough, but for splits, zshrc is definitely sourced but PS1 is not stripped. I will dig through zsh's verbose mode a bit later to see where the newline might be added.
I can't seem to find where and how the newline is added, but instead of sourcing twice, I have added a few lines after sourcing oh-my-zsh:
export PROMPT="$(tr -d '\n' <<< $PROMPT)"
export PS1="$(tr -d '\n' <<< $PS1)"
...
export PS4="$(tr -d '\n' <<< $PS4)"
If anyone else would like to do more digging, I was using the following method:
- Turn on Tmux logging (
<prefix><:>
pipe-pane -o "exec cat >> temp.txt"
) - Run
zsh -v
- Turn off Tmux logging (
<prefix><:>
pipe-pane
) - Exit (
zsh -v
is still running) - Inspect temp.txt for uses of
echo
withoutecho -n
, newline characters, etc.
None of my Linux terminals have such an issue. Also, PS1 and others are BASH prompts, not ZSH ones.
Sorry I didn't update, but at some point I tried Bullet-Train again, and I don't have this issue anymore. I had removed the include guards around oh-my-zsh.sh and the prompt filters before switching back to BT, but left the counter in place; now that I've switched back, whether the counter is 1 or not, BT is honoring the ADD_NEWLINE value. It's my fault for not logging more information when I had the issue, because I've migrated my dotfiles across several kernels, versions of Tmux, etc. and I have no way of reproducing the issue since I never figured out what was even relevant. I'm pretty sure I only set those Bash prompt filters after exhausting all the sane approaches I could think of, and maybe I saw oh-my-zsh**.sh** and took a shot in the dark. Generally if I find a 'solution' I try to regress each change, too, so if the Bash prompt filters were actually necessary, I have even less of an idea what was wrong with my setup.
Currently, I'm on Linux 4.10.0-30, using Zsh 5.1.1. Is anyone still experiencing this issue?