赞
踩
The .bashrc file is a script file that’s executed when a user logs in. The file itself contains a series of configurations for the terminal session. This includes setting up or enabling: coloring, completion, shell history, command aliases, and more.
.bashrc文件是用户登录时执行的脚本文件。该文件本身包含终端会话的一系列配置。 这包括设置或启用:着色,完成,shell历史记录,命令别名等。
It is a hidden file and simple ls command won’t show the file.
To view hidden files, you can run the below command:
要查看隐藏的文件,可以运行以下命令:
$ ls -a
You can see the .bashrc command in the first column. The contents of .bashrc can be changed to define functions, command aliases, and customize the bash.
您可以在第一列中看到**.bashrc命令。 可以更改.bashrc**的内容以定义函数,命令别名和自定义bash。
.bashrc file has a lot of comments that makes it easy to understand.
.bashrc文件包含很多注释,使它易于理解。
To view the bashrc file:
要查看bashrc文件:
$ cat .bashrc
A few examples of editing .bashrc are provided below.
下面提供了一些编辑.bashrc的示例。
bashrc can be used to define functions that reduce redundant efforts. These functions can be a collection of basic commands. These functions can even use arguments from the terminal.
bashrc可用于定义减少冗余工作的功能。 这些功能可以是基本命令的集合。 这些函数甚至可以使用终端中的参数。
Let’s define a function that tells the date in a more descriptive manner.
让我们定义一个以更具描述性的方式告诉日期的函数。
First you’ll need to enter the .bashrc file in editing mode.
首先,您需要在编辑模式下输入.bashrc文件。
$ vi .bashrc
Bashrc FileBashrc文件
This is what the terminal will look like. To start editing press any letter on the keyboard. At the end of the file add the following code:
这就是终端的外观。 要开始编辑,请按键盘上的任意字母。 在文件末尾添加以下代码:
today()
{
echo This is a `date +"%A %d in %B of %Y (%r)"` return
}
Press escape. Then to save and exit from vi, press colon (
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。