我之前尝试将其jhbuild
作为 GTK+ 安装的一部分进行安装,并运行了命令
alias jhbuild="PATH=gtk-prefix/bin:$PATH jhbuild"
。从那时起,我就无法访问许多重要的服务(包括 Homebrew 和 MacPorts),因为显然变量$PATH
已经更改。
问题如下:当我尝试将$PATH
变量重置为默认值(echo $PATH
在我的另一台机器上运行时发现,该机器也运行 OS X 10.8,该机器$PATH
尚未修改)时,我收到以下错误消息:
-bash: alias: `/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin': invalid alias name
如何才能撤消修改后的$PATH
别名?
编辑:正在运行$PATH
(不是 echo $PATH
) 在出现问题的机器上返回
/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin: No such file or directory
编辑:跑步echo $PATH
给予
/Users/[my user name]/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin
这与运行的结果相同$PATH
,但没有错误消息。
编辑:我的~/.bash_profile
文件:
# added by Anaconda 1.5.1 installer
export PATH="/Users/[my user name]/anaconda/bin:$PATH"
我的~/.profile
文件:
# MacPorts Installer addition on 2013-03-12_at_12:06:00: 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.
##
# Your previous /Users/[my user name]/.profile file was backed up as /Users/[my user name]/.profile.macports-saved_2013-03-21_at_16:08:32
##
# MacPorts Installer addition on 2013-03-21_at_16:08:32: 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.
##
# Your previous /Users/[my user name]/.profile file was backed up as /Users/[my user name]/.profile.macports-saved_2013-03-21_at_16:14:16
##
# MacPorts Installer addition on 2013-03-21_at_16:14:16: 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.
我不确定应该在哪里添加/opt/local/bin
Celada 所建议的。
答案1
您提供的别名:
alias jhbuild="PATH=gtk-prefix/bin:$PATH jhbuild"
不会改变默认的$PATH
。事实上,它甚至不会改变$PATH
当前 shell 的。它改变了$PATH
仅有的运行jhbuild
命令。您无需执行“恢复”。即使您更改了$PATH
当前 shell 的,关闭执行该操作的 shell 也足以消除更改。
根据您在尝试将 设置$PATH
为其他内容时收到的非常奇怪的错误消息,我怀疑您之前定义的别名不是您认为定义的别名(引用问题?)。但我无法想象它可能是什么。我无法想象当您尝试$PATH
以任何方式将 重置为 mention 别名时会导致错误消息的原因。
我建议您alias
单独输入不带参数的命令,以查看实际定义了哪些别名。这可能会给您一些线索。