Type a long command in iterm (windowed mode) wraps on the same line.
Hi,
There is an issue that I am trying to solve from a long time. I have installed bash-git-prompt using brew, and have a .git-prompt-colors.sh in my home directory.
When I am using iterm in window mode (not fullscreen) and try to type a command long enough, it wraps on the same line. Here is a screenshot:
If I disable bash-git-prompt, the issue is gone.
Here are the contents of my git-prompt-colors.sh
override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="Custom"
PathShort="\W 🔥 ⚡️ " #Display only the current folder
# Display the current folder first
GIT_PROMPT_START_USER="${Green}${PathShort}"
GIT_PROMPT_START_ROOT="${Green}${PathShort}"
# Skip the default prefix
GIT_PROMPT_PREFIX="${ResetColor}"
# Use whitespace as separator
GIT_PROMPT_SEPARATOR=" "
# Skip remote branch
GIT_PROMPT_REMOTE="${ResetColor}"
GIT_PROMPT_UPSTREAM="${ResetColor}"
# Use yellow for the current branch
GIT_PROMPT_BRANCH="${Yellow}"
# Use red and green for behind and ahead origin
GIT_PROMPT_SYMBOLS_BEHIND="${Red} ↓"
GIT_PROMPT_SYMBOLS_AHEAD="${Green} ↑"
# Add a few emojis to make it fun!
GIT_PROMPT_STAGED=" 👍 "
GIT_PROMPT_CONFLICTS=" ❌ "
GIT_PROMPT_CHANGED=" ✏️ "
GIT_PROMPT_UNTRACKED="❔ "
GIT_PROMPT_STASHED=" 📦 " # A lot nicer than the default flag
GIT_PROMPT_CLEAN=" ✅ "
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING=" 🔒 " # Displayed for untracked brances
# Skip the default suffix
GIT_PROMPT_SUFFIX=" "
# Skip the default ending
GIT_PROMPT_END_USER="${ResetColor}"
GIT_PROMPT_END_ROOT="${ResetColor}"
}
reload_git_prompt_colors "Custom"
Here is another thread I found on the same topic: https://gitlab.com/gnachman/iterm2/issues/239
The solution that it mentions is as follows:
it is most likely because your prompt definition includes sequences that should not be counted in the length of the prompt, such as those for setting colors. These sequences should be between [ and ] to prevent their length from being counted. Here is an example that produces an all-red prompt:
PS1='[\033[31m]\u@\h:\w\$[\033[0m]'
However I am not sure where should I make this change in my setup of bash-git-prompt.
Let me know what is wrong. Any help is super appreciated.
Another potential problem is that your emoji are not single-width characters, meaning that the shell can't calculate the remaining space in the display properly.
On 29 May 2018 at 21:39, Anubhav Yadav [email protected] wrote:
Hi,
There is an issue that I am trying to solve from a long time. I have installed bash-git-prompt using brew, and have a .git-prompt-colors.sh in my home directory.
When I am using iterm in window mode (not fullscreen) and try to type a command long enough, it wraps on the same line. Here is a screenshot:
[image: screenshot 2018-05-29 16 49 23] https://user-images.githubusercontent.com/1628340/40656618-9eda7a52-6362-11e8-8078-ffcbb789dfe9.png
If I disable bash-git-prompt, the issue is gone.
Here are the contents of my git-prompt-colors.sh
override_git_prompt_colors() { GIT_PROMPT_THEME_NAME="Custom"
PathShort="\W 🔥 ⚡️ " #Display only the current folder
Display the current folder first
GIT_PROMPT_START_USER="${Green}${PathShort}" GIT_PROMPT_START_ROOT="${Green}${PathShort}"
Skip the default prefix
GIT_PROMPT_PREFIX="${ResetColor}"
Use whitespace as separator
GIT_PROMPT_SEPARATOR=" "
Skip remote branch
GIT_PROMPT_REMOTE="${ResetColor}" GIT_PROMPT_UPSTREAM="${ResetColor}"
Use yellow for the current branch
GIT_PROMPT_BRANCH="${Yellow}"
Use red and green for behind and ahead origin
GIT_PROMPT_SYMBOLS_BEHIND="${Red} ↓" GIT_PROMPT_SYMBOLS_AHEAD="${Green} ↑"
Add a few emojis to make it fun!
GIT_PROMPT_STAGED=" 👍 " GIT_PROMPT_CONFLICTS=" ❌ " GIT_PROMPT_CHANGED=" ✏️ " GIT_PROMPT_UNTRACKED="❔ " GIT_PROMPT_STASHED=" 📦 " # A lot nicer than the default flag GIT_PROMPT_CLEAN=" ✅ " GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING=" 🔒 " # Displayed for untracked brances
Skip the default suffix
GIT_PROMPT_SUFFIX=" "
Skip the default ending
GIT_PROMPT_END_USER="${ResetColor}" GIT_PROMPT_END_ROOT="${ResetColor}" }
reload_git_prompt_colors "Custom"
Here is another thread I found on the same topic: https://gitlab.com/gnachman/iterm2/issues/239
The solution that it mentions is as follows:
it is most likely because your prompt definition includes sequences that should not be counted in the length of the prompt, such as those for setting colors. These sequences should be between [ and ] to prevent their length from being counted. Here is an example that produces an all-red prompt:
PS1='[\033[31m]\u@\h:\w$[\033[0m]'
However I am not sure where should I make this change in my setup of bash-git-prompt.
Let me know what is wrong. Any help is super appreciated.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/magicmonty/bash-git-prompt/issues/385, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMChcOxvyvRB-E_QQbm2QMf-X0jZUltks5t3TOJgaJpZM4URU_C .
I have the same exact issue as well in iTerm2.