Code Monkey home page Code Monkey logo

macbootstrap's Introduction

介绍

这是一个针对新 Mac 开发的,快速配置开发环境的脚本,里面集成了一些常用的配置。所有的配置和功能都有文档说明, 它既是使用手册,也是教学指南。

读者可以先阅读 这些问题,如果这些问题你并没有简单的方式去实现,那么不妨考虑下 macbootstrap

除非你做过大量配置,而且没有备份,否则也可以推荐使用这个脚本。虽然不能完全保证 100% 的安全,但重要的文件基本上都做了备份,比如原先的 ~/.zshrc 文件会被备份为 ~/.zshrc_backup

我深知,环境配置是一件非常主观的事,不同的人审美和需求不一样,所以如果不愿意使用我的这套配置,也可以看看文档,了解一些好玩的用法,看看它是怎么实现的,然后把部分函数抄走并提高自己的工作效率。

再次警告⚠️, 本项目是为新电脑设计,虽然做了一些保护,请依然谨慎在生产环境中使用此配置,对于因此造成的配置丢失和错乱,作者不负任何责任

安装方式

只需要执行以下代码即可:

curl https://raw.githubusercontent.com/bestswifter/macbootstrap/master/bootstrap.sh | sh

这个命令会安装 HomeBrew,如果是全新的电脑还会安装 Xcode 命令行工具(包括 gcc 等),这是必须的,绝大多数命令行程序都依赖这个。如果安装失败,可以手动执行 xcode-select --install 命令。如果还是无法安装,需要去苹果官网手动下载安装

当然,大概率是不会出现任何问题的。

特色

这份脚本主要包含以下几个方面的配置:

  1. 对系统选项的一些基本修改
  2. 常用的 Homebrew 工具
  3. 基于 zsh 的,能够提高工作效率的命令,包括 git 的快捷命令
  4. Vim 配置
  5. 未来会考虑加入特定软件的配置以及 npm、pip 等依赖的配置

使用文档正在逐步整理中。。。

系统配置

为了增强 Mac OS X 的使用体验,我对系统原生的配置做了一些基本的、必备的修改。

详细的原因、改动方式和效果请参考 系统配置优化 这一节。

Homebrew

如果出现请 The formula built, but is not symlinked into /usr/local 的报错,这可能会导致 link 失败,请执行

sudo chown -R `whoami` /usr/local

具体包含的工具,以及用法请参考: HomeBrew 工具

Zsh

所有 Zsh 相关的函数、配置(主要是对一些 Unix 函数的封装)都在 zsh-config 目录下。

入口文件是 common.sh,其中我个人的配置放在 personalized.sh 中,如果使用者不需要,可以删除这个文件。

具体文档请参考这份说明:Zsh 相关

Git

详细教程请参考这份说明:Git 使用指南

Vim

详细用法与教程请参考这份说明: Vim 使用指南

讨论交流

为了避免无意义的加群,请发送邮件到 [email protected],介绍你对本书的看法和期待,字数不限,我会回复微信号并拉你进群。

内推招聘

头条北京、上海、深圳等地急缺各种开发、运营、产品岗位,点击 此链接 或扫描下发二维码投递简历即可享受内推福利。

头条 iOS 基础技术团队急缺 iOS 工程师,内推通过请吃饭,手把手讲解本书所有内容。。。

What's next

  • [] Add more npm packages
  • [] IMPORTANT: Add demo for this project to show the convenience and advantange of this project

macbootstrap's People

Contributors

bestswifter avatar caimaoy avatar isjaakko avatar promer94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

macbootstrap's Issues

通过路径获取文件名

fullfilename="/etc/apache2/apache2.conf"
filename=$(basename "$fullfilename")
fname="${filename%.*}"
echo $fname

注意校验 coreutils 是否安装

触摸板,轻触替换点击

mojave 10.14.6
原来库里的命令好像没有效果了
我用下面的三行命令,重启电脑,可以实现 tap 替换 click

defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write 'Apple Global Domain' com.apple.mouse.tapBehavior 1

考虑引入 scmpuff

安装:brew install scmpuff
启用:eval "$(scmpuff init -s --aliases=false)"

取消 Caps Lock 和 Ctrl 键对调的方案

很多人问我怎么取消 Caps Lock 和 Ctrl 键对调,我希望大家认真读完这段话:

image

正正反反四条理由已经解释了为什么我要把这个功能设置为默认选项。

关注我的朋友可能知道,我花费了一年的时间,终于在无数博客和 Gist 里面找到了交换这两个键的方案。我真心的希望任何一个,但凡有一点点追求的程序员,都能够选择正确的方式,而不是习惯的方式。因为错的永远对不了,而习惯是可以被培养的。

如果实在不能接受,那么注释掉 ~/.macbootstrap/onlogin.sh 文件中的第一行并重启即可。

hidutil property --set ...

自动输入 password 后结束

npm WARN tern_runtime No repository field.
                                          npm WARN tern_runtime No license field.

                                                                                 up to date in 0.288s
 Vim: Warning: Input is not from a terminal
                                           Password:
                                                    Password:
                                                             Password:

当前行为 1 怎么取消

因为很多时候报错都是报的多少行,然后打开vim、vscode 当前行都是 1,不是很方便查问题

截屏2024-06-23 09 53 19

Auto-map CapsLock and Ctrl

#!/bin/bash

The easiest way to figure this out is to create a re-remapping in System Preferences ui, and then

defaults -currentHost read | grep com.apple.keyboard.modifiermapping

keyboard_id="1452-632-0"
config_key="com.apple.keyboard.modifiermapping.${keyboard_id}"

key_left_cmd=30064771299

key_right_cmd=30064771303
key_esc=30064771113
key_caps_lock=30064771129
key_ctrl=30064771296

plists=ls ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist

/usr/libexec/PlistBuddy -c "Delete $config_key" $plists &> /dev/null
/usr/libexec/PlistBuddy -c "Add $config_key array" $plists

/usr/libexec/PlistBuddy -c "Add $config_key: dict" $plists
/usr/libexec/PlistBuddy -c "Add $config_key:0:HIDKeyboardModifierMappingSrc integer $key_right_cmd" $plists
/usr/libexec/PlistBuddy -c "Add $config_key:0:HIDKeyboardModifierMappingDst integer $key_esc" $plists

/usr/libexec/PlistBuddy -c "Add $config_key: dict" $plists
/usr/libexec/PlistBuddy -c "Add $config_key:1:HIDKeyboardModifierMappingSrc integer $key_caps_lock" $plists
/usr/libexec/PlistBuddy -c "Add $config_key:1:HIDKeyboardModifierMappingDst integer $key_ctrl" $plists

bszip 和 bsunzip

封装系统的 zip 函数。。。。先干掉输出,以及简化一下参数

Vim

vim-surround
vim-airline/vim-airline-themes

fzf

$(brew --prefix)/opt/fzf/install

vim 报错

Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree

这个要如何解决?

gsed 无法安装

gsed 是命令名
通过 brew install gnu-sed 安装
因此不适用 brew_install 函数

HomeBrew 安装加速

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install | sed 's/https:\/\/github.com\/Homebrew\/brew/git:\/\/mirrors.ustc.edu.cn\/brew.git/g' | sed 's/https:\/\/github.com\/Homebrew\/homebrew-core/git:\/\/mirrors.ustc.edu.cn\/homebrew-core.git/g')"

备份 iTerm2 的配置

方法

. 打开终端,删除缓存;输入
defaults delete com.googlecode.iterm2
. 可以看到文件已经清空
把以前老的com.googlecode.iterm2.plist 内容复制粘贴进去
.重新启用配置
defaults read -app iTerm

注意事项

查看哪些会被备份,确保密码不泄露

Vim Error

enter vim a_file it show me the error:

Error detected while processing function <SNR>22_theme_reload:
line    5:
E121: Undefined variable: g:colors_name
E116: Invalid arguments for function writefile
Error detected while processing /Users/lizhi/.config/nvim/config/theme.vim:
line   37:
E185: Cannot find color scheme 'hybrid'
Press ENTER or type command to continue

pressed enter, then it show:

Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree
[dein] command TagbarToggle is not found.
Press ENTER or type command to continue

press enter again, I can edit me file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.