找到丢失的.bash_profile

时间:2016-06-12 18:33:50

标签: bash macos terminal .bash-profile

大约一年前我想编辑.bash_profile在我打开终端时添加一些文本(我在使用最新操作系统的Mac上)。今天,我想改变那个文本,却发现我找不到我编辑过的原始文件。似乎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时弄清楚我的电脑正在读取哪个文件?提前谢谢!

1 个答案:

答案 0 :(得分:1)

  

有没有办法在第一次打开shell时弄清楚我的电脑正在读取哪个文件?

您可以设置在调试PS4中运行bash时使用的-x

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

这将为您提供一些源文件的跟踪,包括在将bash作为交互式登录shell启动时的命令和行号。

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

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

   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 ``+ ''.