如何在我的 mac 上打开新终端 window 时停用 bash_history 统计打印?
How to deactivate bash_history stats print when opening a new terminal window on my mac?
我刚刚重新安装了 MacOS (OSX 10.12),当我重做我的 IDE 时,我得到了这个奇怪的 bash_history 统计对象,它打印到每个新终端 window!这让我发疯,在查看了所有偏好和设置后,我似乎无法将其关闭!有谁知道为什么会突然发生这种情况?这与 iCloud 配置文件同步有关吗?这是下面的图片。非常感谢您的帮助!
Screenshot of bash terminal history stats
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$
所以/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
而/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"
我检查了我的 user/profile 主文件夹,没有 .bashrc...
我遇到了同样的问题,并且已经追踪到在系统上全局安装了 touch
NPM/Node 包,这在你的系统中放置了一个替代的 touch
命令路径。
$ 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
解决了这个问题(我认为 touch
NPM 包是作为我系统的依赖项安装的;它甚至没有正确安装)。
此外,您仅在 Apple 终端中观察到这一点的原因是导致打印统计数据的 touch
命令位于 /etc/bashrc_Apple_Terminal
;它仅通过 /etc/bashrc
中的以下行加载到 Apple 终端中:
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
/etc/bashrc_Apple_Terminal
未加载到其他终端仿真器中(例如您的 platformioIDE 示例)。
我刚刚重新安装了 MacOS (OSX 10.12),当我重做我的 IDE 时,我得到了这个奇怪的 bash_history 统计对象,它打印到每个新终端 window!这让我发疯,在查看了所有偏好和设置后,我似乎无法将其关闭!有谁知道为什么会突然发生这种情况?这与 iCloud 配置文件同步有关吗?这是下面的图片。非常感谢您的帮助!
Screenshot of bash terminal history stats
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$
所以/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
而/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"
我检查了我的 user/profile 主文件夹,没有 .bashrc...
我遇到了同样的问题,并且已经追踪到在系统上全局安装了 touch
NPM/Node 包,这在你的系统中放置了一个替代的 touch
命令路径。
$ 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
解决了这个问题(我认为 touch
NPM 包是作为我系统的依赖项安装的;它甚至没有正确安装)。
此外,您仅在 Apple 终端中观察到这一点的原因是导致打印统计数据的 touch
命令位于 /etc/bashrc_Apple_Terminal
;它仅通过 /etc/bashrc
中的以下行加载到 Apple 终端中:
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
/etc/bashrc_Apple_Terminal
未加载到其他终端仿真器中(例如您的 platformioIDE 示例)。