如何在OSX上编辑$ PATH(.bash_profile)? [英] How do I edit $PATH (.bash_profile) on OSX?

查看:103
本文介绍了如何在OSX上编辑$ PATH(.bash_profile)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试编辑PATH条目,因为做错了什么.

I am trying to edit an entry to PATH, as I did something wrong.

我正在使用Mac OS X 10.10.3

I am using Mac OS X 10.10.3

我尝试过:

> touch ~/.bash_profile; open ~/.bash_profile

但是文件编辑器将打开,里面没有任何内容.

But the file editor opens with nothing inside.

我的问题:

我正在尝试将ANDROID_HOME安装到我的PATH

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.

如何执行所需的设置?

如果我要编辑bash.profile,如何输入上面的代码?

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

它将使用TextEdit打开文件,粘贴您的东西,然后保存.如果再次打开它,您将找到您的编辑内容.

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

但是,如果您不知道如何使用它们,那么使用open方法会更容易.

But if you don't know how to use them, it's easier to use the open approach.

或者,您可以依赖pbpaste.复制

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

在系统剪贴板中,然后在shell中运行

in the system clipboard and then in a shell run

pbpaste > ~/.bash_profile


或者您也可以使用cat

cat > ~/.bash_profile

(现在cat等待输入:粘贴两个导出定义,然后按ctrl-D).

(now cat waits for input: paste the two export definitions and then hit ctrl-D).

这篇关于如何在OSX上编辑$ PATH(.bash_profile)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆