如何创建一个bash别名吗? [英] How do I create a bash alias?
问题描述
我在OSX,我需要把这样的事情,别名等等=的/ usr / bin中/嗒嗒
在配置文件中,但我不知道有其中,config文件。
I'm on OSX and I need to put something like this, alias blah="/usr/bin/blah"
in a config file but I dont know there where the config file is.
推荐答案
您可以添加别名
或函数
在启动脚本文件。通常这是的.bashrc
, .bash_login文件
或 .profile文件
文件在你的home目录。
You can add an alias
or a function
in your startup script file. Usually this is .bashrc
, .bash_login
or .profile
file in your home directory.
由于这些文件是隐藏的,你必须做一个 LS -a
一一列举。如果你没有一个你可以创建一个。
Since these files are hidden you will have to do an ls -a
to list them. If you don't have one you can create one.
如果我没有记错,当我买了我的Mac中, .bash_login文件
文件是不存在。我不得不创建它自己,所以我可以把提示信息
,别名
,功能
等在里面。
If I remember correctly, when I had bought my Mac, the .bash_login
file wasn't there. I had to create it for myself so that I could put prompt info
, alias
, functions
, etc. in it.
下面是具体步骤,如果你想创建一个:
Here are the steps if you would like to create one:
- 启动终端
- 键入
CD〜/
去你的主文件夹 - 键入
触摸的.bash_profile
以创建新的文件。 - 编辑
的.bash_profile
用你喜欢的编辑器(或者你可以键入开放-e的.bash_profile
来打开它在文本编辑。 - 键入
。 .bash_profile中
重新加载的.bash_profile
更新和添加任何别名。
- Start up Terminal
- Type
cd ~/
to go to your home folder - Type
touch .bash_profile
to create your new file. - Edit
.bash_profile
with your favorite editor (or you can just typeopen -e .bash_profile
to open it in TextEdit. - Type
. .bash_profile
to reload.bash_profile
and update any alias you add.
这篇关于如何创建一个bash别名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!