关于macos:mac-相关工具

20次阅读

共计 2869 个字符,预计需要花费 8 分钟才能阅读完成。

hosts 根底批改:

批改 hosts 文件能够应用 SwitchHosts

13.249.146.118 d3mw3wlkjdkqc9.cloudfront.net fastdl.mongodb.org
13.249.146.66 www.mongodb.org
199.232.68.133 raw.githubusercontent.com
13.249.146.118 d3mw3wlkjdkqc9.cloudfront.net fastdl.mongodb.org
185.199.110.154 githubassets.com
13.229.188.59 github.com
140.82.114.3 github.com
185.199.109.153 github.io

以上批改是为了 避免域名解析混同,在装置 Homebrew 等时能够间接拜访,下载 MongoDB 时能够更快下载。

能够通过 ipaddress 网站查问对应域名的 IP 地址。

装置 Homebrew:

装置命令:

上面这种装置形式下载会很慢很慢,能够应用下面提到的批改 hosts 办法批改相干用到的域名的 IP 指向减速下载。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

替换 brew 默认源为国内源:

# 替换 brew.git:
$ cd "$(brew --repo)"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换 homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换 homebrew-bottles:
# 中国科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
# 清华大学:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 利用失效:
$ brew update

重置源:

 重置 brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git

 重置 homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git

 利用失效:
$ brew update

简略应用:

搜寻:brew search
装置:brew install 软件名
卸载:brew remove 软件名

装置 wget

应用 homebrew 装置

$ brew install wget

装置 zsh

mac 自带 zsh, 但不是最新的,查看版本zsh --version
通过 brew 更新最新版,brew install zsh

装置 oh-my-zsh

装置

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

查看以后 shell

echo $SHELL

设置 zsh 为默认终端

chsh -s /bin/zsh

批改主题

装置实现后会自带一些主题,能够到 ~/.oh-my-zsh/themes 目录下查看能够应用的主题。

也能够通过上面的地址下载主题放到 ~/.oh-my-zsh/themes

https://github.com/robbyrusse…

批改主题

1. 关上配置文件:open ~/.zshrc
2. 批改配置文件:ZSH_THEME= 你想要的主题,默认为 robbyrussell
3. 让配置文件失效:source ~/.zshrc
4. 主题举荐:ys,ys 是装置时自带的,无需额定下载

主动补全插件

执行以下命令装置插件,插件会被装置到 ~/.oh-my-zsh/custom/plugins 目录下:

$ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

批改 .zshrc 配置:

1. 编辑 vim .zshrc

2. 找到 `plugins=(git)` 这一行并减少
plugins=(git zsh-autosuggestions)

3. 从新加载配置 source .zshrc

命令高亮插件

装置:

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

批改 .zshrc 配置:

1. 编辑 vim .zshrc

2. 找到 `plugins=(git)` 这一行并减少
plugins=(git zsh-syntax-highlighting)

3. 从新加载配置 source .zshrc

装置 ruby

装置 RVM

首先装置RVM,RVM 是一个便捷的多版本 Ruby 环境的治理和切换工具。

$ curl -sSL https://get.rvm.io | bash -s stable

更新RVM

$ rvm get stable

装置 ruby

列出所有可装置的 ruby

$ rvm list known

装置一个 ruby

$ rvm install 2.6 --default

查看 ruby 版本:

$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]

装置 sass

查看 gem 版本

$ gem --version

装置 sass

$ sudo gem install sass

正文完
 0