macos 终端
You can search Terminal
in Spotlight, or go to the Applications
folder, open the Utilities
subfolder, and look for the Terminal
app.
您可以在Spotlight中搜索“ Terminal
,或转到“ Applications
文件夹,打开“ Utilities
子文件夹,然后查找“ Terminal
应用程序。
When you open it, you’ll get this screen - or something really similar:
当您打开它时,将得到此屏幕-或类似的东西:
The bash-3.2
indicates the type of shell, and its version. New term here - shell. What is a shell? A shell is a program that allows us to interact with the operating system and its applications.
bash-3.2
指示shell的类型及其版本。 此处的新术语-外壳。 什么是贝壳? Shell是一个程序,它使我们可以与操作系统及其应用程序进行交互。
Note: current macOS since Catalina uses zsh. Nothing else changes related to this tutorial
注意:自Catalina使用zsh以来,当前的macOS。 与本教程无关的其他任何更改
There are different kinds of shells: Bash
is one of the most popular. Some people use Fish
(like me), some use Z Shell
, some use other ones.
有多种外壳: Bash
是最受欢迎的外壳之一。 有些人使用Fish
(像我一样),有些人使用Z Shell
,有些人使用其他人。
The shell is basically the program that allows us to enter our commands.
shell基本上是允许我们输入命令的程序。
文件系统命令 (File system commands)
We can start by entering the ls
command, and when we press enter the shell shows us the files contained in the current folder.
我们可以从输入ls
命令开始,然后按Enter键,shell将向我们显示当前文件夹中包含的文件。
The shell normally starts from your home folder, which on a Mac is in /Users/yourname
. How do we know in which folder we currently are? You can get it using the pwd
command:
该外壳程序通常从您的主文件夹开始,在Mac上,该主文件夹位于/Users/yourname
。 我们如何知道我们当前在哪个文件夹中? 您可以使用pwd
命令获取它:
You can change the current folder using cd
:
您可以使用cd
更改当前文件夹:
![](https://flaviocopes.com/macos-terminal/Screen%20Shot%202018-11-02%20at%2007.26.01.png)
If you just type cd
, the shell will get back to your home folder.
如果您仅键入cd
,则外壳程序将返回您的主文件夹。
You can create a new folder using mkdir
:
您可以使用mkdir
创建一个新文件夹:
运行命令 (Running commands)
In the shell you have access to all the programs and files installed on your computer. A lot of stuff.
在外壳程序中,您可以访问计算机上安装的所有程序和文件。 很多东西。
One task you might be required to do, especially when programming in Node and JavaScript, is to use npm
.
您可能需要执行的一项任务是使用npm
,尤其是在使用Node和JavaScript编程时。
npm
is not a command that’s available out of the box, you need to install it from https://www.npmjs.com/get-npm, but when you get it, you can access it from the command line.
npm
不是开箱即用的命令,您需要从https://www.npmjs.com/get-npm安装它,但是当您获取它时,可以从命令行访问它。
Once you do so, you can go into any empty folder and run npm init
to initialize a Node.js project.
完成后,您可以进入任何空文件夹并运行npm init
来初始化Node.js项目。
Once you are ready you can start any Node.js program by running node filename.js
.
准备就绪后,可以通过运行node filename.js
启动任何Node.js程序。
还有更多的东西! (There’s a lot more to it!)
This post can get you started quickly to do the job, and you can explore more advanced features and capabilities of the shell later.
这篇文章可以帮助您快速开始做这项工作,并且以后可以探索Shell的更多高级功能。
macos 终端