How to deactivate bash_history stats print when opening a new terminal window on my mac?

有些话、适合烂在心里 提交于 2019-12-21 21:39:14

问题


I just reinstalled MacOS (OSX 10.12) and as I'm redoing my IDEs and such I get this strange bash_history stats object that prints to every new terminal window! It's driving me bonkers, and after looking through all the preferences an settings I can't seem to turn it off! Does anyone know why this is suddenly happening? Is it something to do with iCloud Profile Syncing? Here's s picture below. Thanks so much for your help!

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$ 

so the /etc/profile is like this:

# 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

and the /etc/bashrc is like this:

# 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"

and I've checked my user/profile home folder and there's no .bashrc...


回答1:


I've had the same problem, and have tracked it down to having the touch NPM/Node package installed globally on the system, which places an alternative touch command in your 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

(I've used yarn global add to install packages on my system rather than npm install -g)

On my system, a simple $ rm /usr/local/bin/touch fixed the issue (I think the touch NPM package got installed as a dependency on my system; it isn't even installed properly).

Also, the reason you only observed this in Apple Terminal is that the touch command which causes the Stat data to be printed is located in /etc/bashrc_Apple_Terminal; which is only loaded in Apple Terminal by the following line in /etc/bashrc:

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

/etc/bashrc_Apple_Terminal isn't loaded in other terminal emulators (e.g. your platformioIDE example).



来源:https://stackoverflow.com/questions/44923968/how-to-deactivate-bash-history-stats-print-when-opening-a-new-terminal-window-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!