Browse Source

Add mac setup

mac-init
Ein Verne 4 years ago
parent
commit
2877f323f9
No known key found for this signature in database
GPG Key ID: 926634D64ACAD792
  1. 15
      .github/workflows/setup.yml
  2. 6
      .zshrc
  3. 111
      Brewfile
  4. 58
      bootstrap.sh
  5. 39
      brew.sh
  6. 12
      curl.cmd
  7. 121
      git/global.gitconfig
  8. 3
      git/work.gitconfig
  9. 28
      init_mac.sh

15
.github/workflows/setup.yml

@ -0,0 +1,15 @@
name: build
on: [push, pull_request]
jobs:
ci:
name: run
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- name: build
env:
CI_MODE: true
run: bash ./bootstrap.sh
- name: CI
run: bash ./test

6
.zshrc

@ -20,13 +20,15 @@ antigen bundle git-flow
antigen bundle mvn antigen bundle mvn
antigen bundle tig antigen bundle tig
antigen bundle heroku antigen bundle heroku
antigen bundle pip
antigen bundle lein antigen bundle lein
antigen bundle command-not-found antigen bundle command-not-found
antigen bundle tmux antigen bundle tmux
antigen bundle tmuxinator antigen bundle tmuxinator
antigen bundle docker antigen bundle docker
antigen bundle docker-compose antigen bundle docker-compose
# macos
antigen bundle brew
antigen bundle osx
# Syntax highlighting bundle. # Syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting antigen bundle zsh-users/zsh-syntax-highlighting
@ -117,6 +119,8 @@ if [[ -f ~/.zshrc.local ]]; then
source $HOME/.zshrc.local source $HOME/.zshrc.local
fi fi
ZSH_DISABLE_COMPFIX=true
fpath=(~/.zsh/completions $fpath) fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit autoload -U compinit && compinit

111
Brewfile

@ -0,0 +1,111 @@
tap "homebrew/cask", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git"
tap "homebrew/cask-drivers", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git"
tap "homebrew/cask-fonts", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git"
tap "homebrew/core", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
tap "homebrew/bundle"
tap "homebrew/services"
tap "homebrew/cask-versions"
tap "adoptopenjdk/openjdk"
# primitives
brew "git"
brew "neovim"
brew "zsh"
brew "zsh-completions"
brew "tmux"
brew "gnupg"
brew "gnupg2"
# tools
brew "wget"
brew "mas"
brew "p7zip"
brew "dos2unix"
brew "proxychains-ng"
brew "htop"
brew "neofetch"
brew "syncthing"
# productivity
brew "exa"
brew "fzf"
brew "ripgrep"
brew "fd"
brew "hexyl"
brew "xsv"
brew "jq"
brew "hledger"
# dev
brew "ruby"
brew "go"
brew "cmake"
# brew "[email protected]"
brew "sqlite"
# brew "postgresql"
brew "youtube-dl"
# brew "heroku"
brew "node"
brew "yarn"
# brew "wrk"
if ENV.key? 'CI_MODE'
cask "eudic"
cask "java"
cask "licecap"
cask "nextcloud"
# cask "1password"
cask "alfred"
cask "google-chrome"
# cask "firefox-developer-edition"
# cask "sublime-text"
cask "visual-studio-code"
cask "iterm2"
cask "font-source-code-pro"
cask "font-fira-code"
cask "dash"
cask "karabiner-elements"
cask "dozer"
cask "shadowsocksx-ng"
cask "iina"
cask "neteasemusic"
# cask "qqmusic"
cask "google-trends"
cask "appcleaner"
cask "oversight"
# cask "dropbox"
cask "nitroshare"
cask "qmk-toolbox"
cask "via"
mas "WeChat", id: 836500024
mas "Unsplash Wallpapers", id: 1284863847
mas "Microsoft ToDo", id: 1274495053
mas "Microsoft OneNote", id: 784801555
# mas "Bear", id: 1091189122
# mas "Lungo", id: 1263070803
mas "Pages", id: 409201541
mas "Numbers", id: 409203825
mas "Keynote", id: 409183694
end
brew "[email protected]"
brew "readline"
brew "asdf"
brew "[email protected]", link: true
brew "cmake"
brew "fzf"
brew "git"
brew "hub"
brew "jenv"
brew "node"
brew "privoxy"
brew "pyenv"
brew "sqlite"
brew "tmux"
brew "tree"
brew "wget"
brew "xz"
brew "zlib"

58
bootstrap.sh

@ -0,0 +1,58 @@
#!/usr/bin/env bash
# https://github.com/crispgm/dotfiles/blob/master/bootstrap
set -e
echo "Install Homebrew"
if test ! $(which brew); then
echo "Installing homebrew..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo "Setup hostname"
sudo scutil --set HostName mac
echo "Install with Brew Bundle"
set +e
brew bundle
set -e
echo "Setup workspace"
mkdir -p ~/projects
echo "Setup Git"
ln -s ./git/work.gitconfig ~/projects/.gitconfig
ln -s ./git/global.gitconfig ~/.gitconfig
# echo "Setup Bash"
# sudo cp ./motd /etc/motd
# cp ./bash/.bashrc ~/.bashrc
# cp ./bash/.bash_profile ~/.bash_profile
echo "Setup Zsh"
sudo sh -c 'echo /usr/local/bin/zsh >> /etc/shells'
sudo chsh -s $(which zsh)
ln -s .zshrc ~/.zshrc
source ~/.zshrc
echo "Setup applications"
echo "- fzf"
$(brew --prefix)/opt/fzf/install
# echo "- neovim"
# ./neovim/neovim
echo "Link editors"
mkdir -p ~/Applications/
sudo ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code
# echo "Setup Ruby"
# ./ruby/ruby
#
# echo "Setup Go"
# mkdir -p ~/go
#
# echo "Setup Shadowsocks"
# ./Shadowsocks/init
echo "Setup macOS defaults"
./init_mac.sh

39
brew.sh

@ -0,0 +1,39 @@
# https://github.com/mathiasbynens/dotfiles/blob/main/brew.sh
brew update
brew upgrade
# https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands
brew install coreutils
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, `g`-prefixed.
brew install findutils
# Install GNU `sed`, overwriting the built-in `sed`.
brew install gnu-sed --with-default-names
# Install `wget` with IRI support.
brew install wget --with-iri
# Install GnuPG to enable PGP-signing commits.
brew install gnupg
# Install more recent versions of some macOS tools.
brew install vim --with-override-system-vi
brew install grep
brew install openssh
# GNU multiple precision arithmetic library
brew install gmp
# Install font tools.
# brew tap bramstein/webfonttools
# brew install sfnt2woff
# brew install sfnt2woff-zopfli
# brew install woff2
brew install ack
brew install git
brew install git-lfs
brew install imagemagick --with-webp
brew install p7zip
brew install ssh-copy-id
brew install tree
# Remove outdated versions from the cellar.
brew cleanup

12
curl.cmd

@ -1,12 +0,0 @@
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@curl.exe %*

121
git/global.gitconfig

@ -0,0 +1,121 @@
[user]
name = Ein Verne
email = [email protected]
[core]
editor = vim
autocrlf = input
[alias]
a = add
b = branch
c = commit
d = diff
f = fetch
g = grep
l = log
m = merge
o = checkout
p = pull
r = remote
s = status
st = status
w = whatchanged
### commit ###
ca = commit --amend
### checkout ###
co = checkout
### cherry-pick ###
### diff ###
# diff - show changes not yet staged
dc = diff --cache
# diff - changes about to be commited
ds = diff --staged
### log ###
# log key - our favorite way to show our key performance indicators, i.e. our most useful summary.
lk = log --graph --topo-order --abbrev-commit --date=short --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset'
### merge ###
### pull ###
# pull if a merge can be resolved as a fast-forward, otherwise fail.
pf = pull --ff-only
# pull with rebase - to provide a cleaner, linear, bisectable history.
#
# To integrate changes between branches, you can merge or rebase.
#
# When we use "git pull", git does a fetch then a merge.
# If we've made changes locally and someone else has pushed changes
# to our git host then git will automatically merge these together
# and create a merge commit that looks like this in the history:
#
# 12345678 - Merge branch 'foo' of bar into master
#
# When we use "git pull --rebase", git does a fetch then a rebase.
# A rebase resets the HEAD of your local branch to be the same as
# the remote HEAD, then replays your local commits back into repo.
# This means you don't get any noisy merge messages in your history.
# This gives us a linear history, and also helps with git bisect.
#
# To automatically do "pull --rebase" for any branch based on master:
#
# git config branch.master.rebase true
#
# To automatically do "pull --rebase" for all branches:
#
# git config --global branch.autosetuprebase always
#
pr = pull --rebase
### rebase ###
# rebase - forward-port local commits to the updated upstream head.
rb = rebase
# rebase - continue the rebasing process after resolving a conflict manually and updating the index with the resolution.
rbc = rebase --continue
# rebase - restart the rebasing process by skipping the current patch.
rbs = rebase --skip
### remote ###
### tags ###
lasttag = describe --tags --abbrev=0
tags = tag -n1 --list
# Stash aliases
save = stash save
pop = stash pop
[branch]
autosetuprebase = always
[pull]
rebase = true
[push]
default = matching
[gc]
autoDetach = false
[gpg]
program = gpg2
[commit]
gpgSign = false
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[diff]
tool = meld
[difftool]
prompt = false
[includeIf "gitdir:~/projects/"]
path = ~/projects/.gitconfig

3
git/work.gitconfig

@ -0,0 +1,3 @@
[user]
name = Ein Verne
email = [email protected]

28
init_mac.sh

@ -0,0 +1,28 @@
# https://github.com/mathiasbynens/dotfiles/blob/master/.macos
# Disable Notification Center and remove the menu bar icon
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null
# Trackpad: enable tap to click for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Trackpad: map bottom right corner to right-click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true
# Open Desktop
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
defaults write com.apple.finder ShowPathbar -bool true
# Dock
defaults write com.apple.dock tilesize -int 36
defaults write com.apple.dock show-process-indicators -bool true
defaults write com.apple.dock minimize-to-application -bool true
defaults write com.apple.dock show-recents -bool false
# Terminal utf-8
defaults write com.apple.terminal StringEncodings -array 4
# Left corner to screensaver
defaults write com.apple.dock wvous-bl-corner -int 5
# Avoid create DS_Store to USB
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
Loading…
Cancel
Save