ホーム 暮らし [Archived] What is zshrc? Let's take a look at its contents.

[Archived] What is zshrc? Let's take a look at its contents.

篠原 沙世 篠原 沙世 • 更新: • 公開: • 読了約 7 分
目次

Last time, we took a brief look at "zsh" and "bash", which are types of shell software. (Click here for the previous article)

Today, I would like to look at "zshrc", which is related to this.

1. What does the "rc" in zshrc mean?

ne9825624fe93

Not just for zshrc, but there are also bashrc, vimrc, etc., and this stands for "Run Command".

Therefore, zshrc means "commands to run zsh".

2. Let's take a look at zshrc.

Let's use the vi editor to look at zshrc.

By the way, if you are wondering "What is the vi editor?", please refer to this article.

Let's try entering the following command into the terminal.

vi ~/.zshrc

When I opened it, it looked like this screen.

First, let's focus on the left side.

3. What is the export command?

What is this "export"?

export PS1="%~ %n " ...

"export" is a command used to define "environment variables".

If you are wondering "What are environment variables?", please check here.

https://wa3.i-3-i.info/word11027.html

According to this site, it is "variables held by the OS".

Now, let's take a look at the settings for environment variables, which are the variables held by the OS.

4. What is PS1?

Next, let's look at this.

export PS1="%~ %n " ...

First, PS seems to be an abbreviation for "Prompt Statement".

As the name suggests, this represents the display format of the prompt.

"%~ %n "

This indicates that this is the display format.

For example, "%n" represents the username. If you look at the terminal,

My username is shown like this.


5. PATH settings

Let's look at this as well.

First, since PATH means "path" in English, it is an environment variable that indicates where a file is located.

PATH=$HOME/.nodebrew/current/bin:$PATH

In other words, it simply indicates that "$HOME/.nodebrew/current/bin" is the location.

Once you know where it is, you can execute the file.


6. What is the source command?

The PS1 mentioned in 4 was the terminal display format.

This means there will be times when you want to change the display format. In such cases, using only the "export" command mentioned in 3 will not reflect the changes.

The "source" command is what "reflects" the changes in such situations.

It is a command designed to properly apply changes from the "source (origin, root)" rather than just the surface level.


How was it?

Commands may seem difficult at first glance, but if you look at them one by one, it seems you can properly decipher them.

Thank you for reading until the end today as well.



同じカテゴリの記事

篠原 沙世

アニメとゲームの新作情報を担当。制作会社・配信元の公式告知と登壇情報を照合して記事化します。

おすすめの関連記事