Search code examples
terminalzshiterm2oh-my-zsh

How do I get rid of an unassigned "1" that appears in iterm2's input field with every new window?


When using iTerm2, every time I open it or open a new window, a 1 automatically appears in the input field and in the "last login" string above it. In the last login string, it appears before "Last login" when I first open iTerm, but appears as 1% on a new line when I open a new window.

I use the latest iTerm (3.3.7), as well as oh-my-zsh. I don't have anything defined as a command to run at the start of a session in iTerm's preferences. Up until this last update, I was able to keep the dreaded "1" from appearing by adding prompt_context () { } to my .zshrc file — but even that doesn't seem to help anymore. That said, if I completely delete the .zshrc file, the problem still persists.

Here's my current .zshrc file (minus a bunch of auto-generated, commented out lines):

ZSHING_PLUGINS=(
"https://gitlab.com/zakariaGatter/zshing"
)

# source zshing plugin 
source $HOME/.zshing/zshing/zshing.zsh

# Path to your oh-my-zsh installation.
export ZSH="/Users/dc/.oh-my-zsh"

ZSH_THEME=powerlevel10k/powerlevel10k

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"POWERLEVEL9K_MODE='nerdfont-complete'
source ~/powerlevel9k/powerlevel9k.zsh-theme

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
  git-flow-completion
  zsh-syntax-highlighting
  zsh-autosuggestions
)

source $ZSH/oh-my-zsh.sh

# User configuration

export EDITOR="/usr/local/bin/atom --wait"
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh

POWERLEVEL9K_MODE='nerdfont-complete'
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUN=4
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_DISABLE_PROMPT=true
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="▶ "
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=""
alias ls='ls -G'

# redefine prompt_context for hiding user@hostname
prompt_context () { }

eval $(thefuck --alias)
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

Here's an image of what happens when I open iTerm2 (I tried to add clear as a command to run at the start of a session to mitigate the problem via general config, but it just ended up sending 1clear instead, so that's why the autocomplete shows what it does): https://i.gyazo.com/4c6cf3826a2da40d5a8fe225b7d030c7.png

Here's an image of what happens when I open a new iTerm2 window from an existing session: https://i.gyazo.com/06c3ce5727afe053e4f9ec2cd07c26f0.png

Here's an image of my profile's general config — I originally just put the clear in the "send text at start" option: https://i.gyazo.com/1c3d407686047ddf1fddd957b209bef4.png

Thanks in advance to anyone who takes the time to help!


Solution

  • I'm not quite sure why this worked, but this fixed it:

    1. Go to iTerm2 > Preferences > Profiles > Window
    2. Under the "Settings for New Windows" section, change the "Space" setting from the dropdown to "Current Space"