初次使用Mac的记录

之前没用过Mac,心想还不是和Ubuntu一样,但是还真的没法立即上手。第一关就是键盘,Mac上取代“alt”键位置的是“command”键,而在Windows中的与“ctrl”相关的快捷键很多变为与“command”关联。有关类似的Mac上的基本操作,在知乎中找到了一篇不错的文章,地址为:https://www.zhihu.com/question/33887923/answer/57480318。

打开Mac自带的Terminal,默认配色白底黑字也是丑的没谁了,我换成了Solarized配色,虽然还是不怎么好看但是总比原来强,之后有时间再折腾,Solarized配色的地址为:http://ethanschoonover.com/solarized/vim-colors-solarized。

我还希望可以拥有一个快捷键来全局开启Terminal,网上搜索之后发现可以使用自带的“Automator”新建服务后添加快捷键来实现。可以说“Automator”是一个比较令我惊喜的东西,它可以定制许多计算机中的处理流程,这里找到了一个介绍它功能的文章,地址为:http://blog.sina.com.cn/s/blog_721fa23b0100pjw2.html。

Mac中流行的应用程序管理器为Homebrew,地址为:https://brew.sh。

本来想使用Homebrew安装nvm(node版本管理工具),但是使用这种方式安装nvm是存在问题无法使用的,之后在nvm的README中也有看到,其中明确写明不支持使用Homebrew进行安装。

# Homebrew installation is not supported. If you have issues with homebrew-installed nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.

地址为:https://github.com/creationix/nvm/blob/master/README.md。

最终只能跟着nvm的README的安装步骤慢慢来,这是在配置环境变量的时候,发现对于配置环境变量时常遇到的这几个文件并不熟悉,于是来了解一下。

1)/etc/profile: 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行。并从/etc/profile.d目录的配置文件中搜集shell的设置。

英文描述为:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

2)/etc/bashrc:为每一个运行bash shell的用户执行此文件。当bash shell被打开时,该文件被读取。

英文描述为:

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

3)如果你想对所有的使用bash的用户修改某个配置并在以后打开的bash都生效的话可以修改这个文件,修改这个文件不用重启,重新打开一个bash即可生效。

~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。

此文件类似于/etc/profile,也是需要需要重启才会生效,/etc/profile对所有用户生效,~/.bash_profile只对当前用户生效。

~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取。(每个用户都有一个.bashrc文件,在用户目录下)

此文件类似于/etc/bashrc,不需要重启生效,重新打开一个bash即可生效,/etc/bashrc对所有用户新打开的bash都生效,但~/.bashrc只对当前用户新打开的bash生效。

~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件。


/etc/profile中设定的变量(全局)可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。


~/.bash_profile 是交互式、login 方式进入bash 运行的。
~/.bashrc 是交互式 non-login 方式进入bash 运行的。
通常二者设置大致相同,所以通常前者会调用后者。

猜你喜欢

转载自www.cnblogs.com/SyMind/p/9276523.html