如何创建一个bash别名吗? [英] How do I create a bash alias?

查看:85
本文介绍了如何创建一个bash别名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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:


  1. 启动终端

  2. 键入 CD〜/ 去你的主文件夹

  3. 键入触摸的.bash_profile 以创建新的文件。

  4. 编辑的.bash_profile 用你喜欢的编辑器(或者你可以键入开放-e的.bash_profile 来打开它在文本编辑。

  5. 键入。 .bash_profile中重新加载的.bash_profile 更新和添加任何别名。

  1. Start up Terminal
  2. Type cd ~/ to go to your home folder
  3. Type touch .bash_profile to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type open -e .bash_profile to open it in TextEdit.
  5. Type . .bash_profile to reload .bash_profile and update any alias you add.

这篇关于如何创建一个bash别名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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