iterm2_shell_integration and Python virtualenv causes a prompt split into 2 lines
Hi, I'm having problems with the prompt when I use iterm2_shell_integration
script together with activating a Python virtualenv
.
The effect is that I get 2 markers and 2 prompt lines instead of one. I use Zsh, but I disabled all my startup scripts to show the effect on a bare zsh:
hostname% source venv/bin/activate (venv)hostname% (venv)hostname% deactivate hostname% source ~/.iterm2_shell_integration.zsh →hostname% source venv/bin/activate →(venv) →hostname%
- iTerm2 version: Build 2.9.20160206
- OS version: 10.10.5
I can provide further information if it will help.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Owner
What is
$PS1
prior to loading shell integration? - Author
In the case of the example, it was the zsh default:
echo $PS1 %m%#
I have the same problem with my customised prompt.
- Owner
Looks like a dup of #4018 (closed). How long ago did you install shell integration? If it's been a while, please reinstall because the script has been updated to fix the issue.
I wasn't able to reproduce it locally, so I'm pretty sure this will do the job.
If not, I'd love to know what the output of
echo $PS1 | less
gives. - Author
I downloaded the shell integration script yesterday and again today (same version). The problem still occurs in my ZSH.
Output of echo
$PS1 | less
looks like this:(blank line) %m%# (END)
Note the extra blank line at the top. If I re-run the
$PS1 | less
, then I get 2 extra lines, next time 3 extra lines, etc.Edited by username-removed-422338 - Owner
I think I've fixed this. Would you mind testing an updated script located here: https://raw.githubusercontent.com/gnachman/iterm2-website/master/source/misc/zsh_startup.in
Just copy it over
$HOME/.iterm2_shell_integration.zsh
.If it looks good I'll push it to production.
- Author
It looks good. The issue seems fixed.
- Owner
I asked folks to twitter to test it out. If nobody finds an issue I'll push it.
- Owner
Seems to break OhMyZsh if loaded prior to it. https://twitter.com/wadey/status/702257305727983618
- Author
I can confirm that tweet. I does indeed break OhMyZsh if loaded before it. Removing the following line does seem to fix it.
iterm2_decorate_prompt
- Owner
That line has been removed in 733a5e751ef60ff69b4941df70fcd38856b658ef
- username-removed-55954 Milestone changed to Ship 3.0
Milestone changed to Ship 3.0
- username-removed-55954 Status changed to closed
Status changed to closed
Same problem for me (latest version of
.iterm2_shell_integration.bash
), still not resolve completely.- Owner
@Leechael Can you give me more details? Here's what I see when I try using bash (→ is the shell integration mark indicator)
Georges-iMac:~ gnachman$ cd /tmp/bug Georges-iMac:bug gnachman$ source venv/bin/activate (venv)Georges-iMac:bug gnachman$ deactivate Georges-iMac:bug gnachman$ source ~/.iterm2_shell_integration.bash →Georges-iMac:bug gnachman$ source venv/bin/activate →(venv)Georges-iMac:bug gnachman$
leechael at Latte in /tmp 2016-06-20 16:28 $ cd /tmp leechael at Latte in /tmp 2016-06-20 16:28 $ pyvenv-3.5 bug leechael at Latte in /tmp 2016-06-20 16:28 $ source bug/bin/activate (bug) leechael at Latte in /tmp 2016-06-20 16:28 $ deactivate leechael at Latte in /tmp 2016-06-20 16:28 $ source ~/.iterm2_shell_integration.bash leechael at Latte in /tmp 2016-06-20 16:28 $ source bug/bin/activate (bug) leechael at Latte in /tmp 2016-06-20 16:28 $
My
.iterm2_shell_intergration.bash
:2016-06-20 16:28 $ md5sum ~/.iterm2_shell_integration.bash 69aacfb872be678b68ac457b1d846b09 /Users/leechael/.iterm2_shell_integration.bash
- Owner
Not sure how to install pyenv-3.5. My version is:
bash-4.3$ ~/.pyenv/bin/pyenv --version pyenv 20160509-38-gf64f7c7
I can't do
pyenv bug
:bash-4.3$ pyenv bug pyenv: no such command `bug'
My pyvenv come with Python 3.5 and installed by homebrew:
2016-06-22 11:16 $ ls -l $(which pyvenv) lrwxr-xr-x 1 leechael admin 34 Oct 31 2015 /usr/local/bin/pyvenv -> ../Cellar/python3/3.5.0/bin/pyvenv
- Owner
Oh, I misread
pyvenv
aspyenv
. That explains that.What do you have that is printing
leechael at Latte in /tmp
? That's probably involved. Small snippet from my .profile file:
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt” # Shamelessly copied from https://github.com/gf3/dotfiles # Screenshot: http://i.imgur.com/s0Blh.png if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color elif infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color fi if tput setaf 1 &> /dev/null; then tput sgr0 if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then MAGENTA=$(tput setaf 9) ORANGE=$(tput setaf 172) GREEN=$(tput setaf 190) PURPLE=$(tput setaf 141) WHITE=$(tput setaf 7) else MAGENTA=$(tput setaf 5) ORANGE=$(tput setaf 4) GREEN=$(tput setaf 2) PURPLE=$(tput setaf 1) WHITE=$(tput setaf 7) fi BOLD=$(tput bold) RESET=$(tput sgr0) else MAGENTA="\033[1;31m" ORANGE="\033[1;33m" GREEN="\033[1;32m" PURPLE="\033[1;35m" WHITE="\033[1;37m" BOLD="" RESET="\033[m" fi export MAGENTA export ORANGE export GREEN export PURPLE export WHITE export BOLD export RESET function parse_git_dirty() { [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" } function parse_git_branch() { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\n\[$WHITE\]\$(date +'%Y-%m-%d %H:%M') \$ \[$RESET\]" export PS2="\[$ORANGE\]→ \[$RESET\]"