如何在 OS X 上编辑 $PATH (.bash_profile)? [英] How do I edit $PATH (.bash_profile) on OS X?
问题描述
我正在尝试编辑 PATH 的条目,因为我做错了什么.
我使用的是 Mac OS X v10.10.3 (Yosemite)
我试过了:
touch ~/.bash_profile;打开 ~/.bash_profile
但是文件编辑器打开时里面什么也没有.
我的问题:
我正在尝试将 ANDROID_HOME 安装到我的 PATH
我拼错了,但是当我关闭终端并返回时它不见了,所以我又试了一次:
<块引用>export ANDROID_HOME=/<安装位置>/android-sdk-macosx导出路径=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
这一次,我正确输入了命令,但是当我关闭终端时,我的设置又消失了.
如何执行我想要的设置?
如果我要编辑 bash.profile,我该如何输入上面的代码?
您必须使用文本编辑器打开该文件,然后将其保存.
touch ~/.bash_profile;打开 ~/.bash_profile
它将使用 TextEdit 打开文件,粘贴您的内容,然后保存.如果您再次打开它,您会发现您所做的编辑.
您可以使用其他编辑器:
nano ~/.bash_profile队友 ~/.bash_profilevim ~/.bash_profile
但如果您不知道如何使用它们,则使用 open
方法会更容易.
或者,您可以依赖 pbpaste
.复制
export ANDROID_HOME=/<安装位置>/android-sdk-macosx导出路径=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
在系统剪贴板中,然后在 shell 中运行
pbpaste >~/.bash_profile
或者你也可以使用 cat
cat >~/.bash_profile
(现在 cat
等待输入:粘贴两个导出定义,然后按 Ctrl + D).
I am trying to edit an entry to PATH, as I did something wrong.
I am using Mac OS X v10.10.3 (Yosemite)
I have tried:
touch ~/.bash_profile; open ~/.bash_profile
But the file editor opens with nothing inside.
My problem:
I am trying to install ANDROID_HOME to my PATH
I misspelled it, but when I closed the terminal and went back it was gone, so I tried again:
export ANDROID_HOME=/<installation location>/android-sdk-macosx export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
This time, I typed the command correctly but, when I closed the terminal, my settings disappeared again.
How do I execute my desired settings?
If I was to edit bash.profile, how would I enter the above code?
You have to open that file with a text editor and then save it.
touch ~/.bash_profile; open ~/.bash_profile
It will open the file with TextEdit, paste your things and then save it. If you open it again you'll find your edits.
You can use other editors:
nano ~/.bash_profile
mate ~/.bash_profile
vim ~/.bash_profile
But if you don't know how to use them, it's easier to use the open
approach.
Alternatively, you can rely on pbpaste
. Copy
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
in the system clipboard and then in a shell run
pbpaste > ~/.bash_profile
Or alternatively you can also use cat
cat > ~/.bash_profile
(now cat
waits for input: paste the two export definitions and then hit Ctrl + D).
这篇关于如何在 OS X 上编辑 $PATH (.bash_profile)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!