首页 > 解决方案 > 如何摆脱每个新窗口出现在 iterm2 的输入字段中的未分配的“1”?

问题描述

使用 iTerm2 时,每次打开或打开新窗口时,1输入字段和其上方的“上次登录”字符串中都会自动出现一个。在上次登录字符串中,当我第一次打开 iTerm 时,它出现在“上次登录”之前,1%但当我打开新窗口时,它显示为新行。

我使用最新的 iTerm (3.3.7) 以及 oh-my-zsh。在 iTerm 的首选项中,我没有任何定义为在会话开始时运行的命令。在最后一次更新之前,我可以通过添加prompt_context () { }到我的 .zshrc 文件中来防止可怕的“1”出现——但即使这样似乎也没有帮助了。也就是说,如果我完全删除 .zshrc 文件,问题仍然存在。

这是我当前的 .zshrc 文件(减去一堆自动生成的注释掉的行):

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

这是我打开 iTerm2 时发生的情况的图像(我尝试添加clear为在会话开始时运行的命令,以通过常规配置缓解问题,但它最终只是发送1clear,所以这就是自动完成显示它的原因确实): https ://i.gyazo.com/4c6cf3826a2da40d5a8fe225b7d030c7.png

这是我从现有会话中打开新 iTerm2 窗口时发生的情况的图像:https ://i.gyazo.com/06c3ce5727afe053e4f9ec2cd07c26f0.png

这是我的个人资料的一般配置图像 - 我最初只是将clear“在开始时发送文本”选项放入: https ://i.gyazo.com/1c3d407686047ddf1fddd957b209bef4.png

提前感谢任何花时间提供帮助的人!

标签: terminalzshiterm2oh-my-zsh

解决方案


我不太确定为什么会这样,但这解决了它:

  1. 转到 iTerm2 > 首选项 > 配置文件 > 窗口
  2. 在“新窗口设置”部分下,将“空间”设置从下拉列表更改为“当前空间”

推荐阅读