tput:Sublime Text3中没有$ TERM值,也没有指定-T

时间:2018-08-13 13:33:14

标签: bash macos terminal sublimetext3

当我在Sublime Text3中构建C ++编程时,在任何控制台输出的开头都会出现以下几行:

Sublime Build Output

这是我的~/.bash_profile的内容:

# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

export PATH


# added by Anaconda3 5.0.1 installer
export PATH="/Users/zhuliwen/anaconda3/bin:$PATH"
export CLICOLOR=1  
export LSCOLORS=gxfxaxdxcxegedabagacad  

# export PS1="\[\033[38;5;10m\]\u@\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tp    ut sgr0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]"
# export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput     sgr0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]"
export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sg    r0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)    \]"

alias ls='ls -G'
alias grep='grep --color' 

如何解决此问题?谢谢

1 个答案:

答案 0 :(得分:1)

通过这样的应用程序进行构建时,通常没有用于输出的真实终端(但是如您所见,您可以运行shell脚本)。避免出现该信息的方法

  • 修改bash配置文件,使其仅在交互式会话时才执行这些分配-或输出满足Shell对“ tty”的检查,例如
    if [ -t 0 ]
    then
        export PS1="\[\033[38;5;10m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sg    r0)\]\[\033[38;5;220m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)    \]"
    fi
  • 或者,您可以将TERM设置为匹配开发人员声称输出“终端”匹配的内容。有时行得通。