寻找丢失的 .bash_profile

Finding a missing .bash_profile

大约一年前,我想编辑 .bash_profile 以在打开终端时添加一些文本(我在 Mac 上使用最新的 OS)。今天想改一下那个文字,却发现找不到我编辑的原文件了。好像MacPorts动了点什么,因为我可以在.bash_profile文件上加文字,但是我去年做的原文不在文件里,删不掉.

这是我现在的.bash_profile:

export PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"

##
# Your previous /Users/nathanielhoffman/.bash_profile file was backed up as /Users/nathanielhoffman/.bash_profile.macports-saved_2015-10-11_at_12:31:11
##

# MacPorts Installer addition on 2015-10-11_at_12:31:11: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

在您提问之前,是的,我已经检查了 .profile 和 .bashrc。那里空无一物。该备份配置文件中没有任何内容 MacPorts 表示它已经制作了任何一个。在此文件末尾添加 'echo "hello world" ' 之类的文本将在神秘文本源下添加该文本。

有什么方法可以让我在第一次打开 shell 时确定我的计算机正在读取哪个文件?提前致谢!

Is there a way I can figure out which file my computer is reading when it first opens up a shell?

可以在debug 运行ning bash时设置PS4 -x:

PS4='+ $BASH_SOURCE:$LINENO: ' bash -xlic ""

这会让您跟踪启动 bash 作为交互式登录 shell.

时来源的文件,包括命令和行号

-x跟踪,-l是登录shell,-i是交互,-c ''是对运行的命令。

有关 PS4 的信息,请参阅 man bash

   PS4    The  value  of  this parameter is expanded as with PS1 and the value
          is printed before each command bash displays during an execution trace.
          The first character of PS4 is replicated multiple times, as necessary,
          to indicate multiple levels of indirection. The default is ``+ ''.