如何在我的Mac上打开一个新的终端窗口时停用bash_history stats打印?

Mat*_*son 2 macos bash terminal .bash-profile macos-sierra

我刚刚重新安装了MacOS(OSX 10.12),因为我正在重做我的IDE,所以我得到了这个奇怪的bash_history stats对象,它打印到每个新的终端窗口!它让我疯狂,在查看了所有的偏好设置后,我似乎无法将其关闭!有谁知道为什么突然发生这种情况?是否与iCloud Profile Syncing有关?这是下面的图片.非常感谢你的帮助!

bash终端历史统计信息的屏幕截图

Last login: Wed Jul  5 03:23:51 on ttys005
/Users/admin/.bash_sessions/5D8EB886-1FE8-4DF6-AC4C-6ACE7B8CF803.historynew Stats {
dev: 16777220,
mode: 33152,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 1411298,
size: 0,
blocks: 0,
atime: 2017-07-05T10:24:18.000Z,
mtime: 2017-07-05T10:24:18.000Z,
ctime: 2017-07-05T10:24:18.000Z,
birthtime: 2017-07-05T10:24:18.000Z }
CafeMisto:~ admin$ 
Run Code Online (Sandbox Code Playgroud)

所以/ etc/profile是这样的:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi
Run Code Online (Sandbox Code Playgroud)

在/ etc/.bashrc中是这样的:

# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi

PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize

[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
Run Code Online (Sandbox Code Playgroud)

我已经检查了我的用户/个人资料主文件夹,并且没有.bashrc ...

小智 5

我遇到了同样的问题,并已将其跟踪到touch在系统上全局安装NPM/Node程序包,这会touch在PATH中放置一个替代命令.

$ ls -l $(which touch) lrwxr-xr-x 1 timshel admin 74 18 Jul 12:47 /usr/local/bin/touch -> ../../../Users/timshel/.config/yarn/global/node_modules/touch/bin/touch.js

(我以前yarn global add在我的系统上安装软件包而不是npm install -g)

在我的系统上,一个简单$ rm /usr/local/bin/touch的问题就解决了(我认为touchNPM软件包是作为对我系统的依赖而安装的;它甚至没有正确安装).

此外,您在Apple终端中仅观察到这一点的原因是touch导致Stat数据被打印的命令位于/etc/bashrc_Apple_Terminal; 仅通过以下行在Apple终端中加载/etc/bashrc:

[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

/etc/bashrc_Apple_Terminal 未在其他终端仿真器中加载(例如您的platformioIDE示例).