sh macOS Sierra自分なりの环境构筑スクリプト(通しで走らせたことがないので动くかは不明)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh macOS Sierra自分なりの环境构筑スクリプト(通しで走らせたことがないので动くかは不明)相关的知识,希望对你有一定的参考价值。

#!/bin/bash
# Xcode
xcode-select --install

# HomeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install p7zip git wget bash-completion vim subversion

# HomeBrew Cask
brew tap caskroom/cask
brew cask install caskroom/versions/google-chrome-beta chromium firefox visual-studio-code google-japanese-ime docker-edge fork filezilla transmit skype adobe-creative-cloud avocode microsoft-office dropbox scroll-reverser istat-menus kodi amazon-music

# Adobe CC インストーラーを起動
open -a /usr/local/Caskroom/adobe-creative-cloud/latest/Creative\ Cloud\ Installer.app

# Git の設定
read -p "git global user.name: " gitName
git config --global user.name $gitName
read -p "git global user.email: " gitEmail
git config --global user.email $gitEmail
git config --global core.quotepath false

# 共通設定
defaults write NSGlobalDomain com.apple.keyboard.fnState -bool true
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 35
defaults write NSGlobalDomain AppleAquaColorVariant -int 6
defaults write NSGlobalDomain AppleHighlightColor -string "1.000000 0.733333 0.721569";
defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark"

# メニューバーの設定
defaults write com.apple.menuextra.clock DateFormat -string "M\u6708d\u65e5(EEE)  H:mm:ss"

# Dock の設定
defaults write com.apple.dock tilesize -int 45
defaults write com.apple.dock magnification -bool yes
defaults write com.apple.dock largesize -int 75
defaults write com.apple.dock wvous-br-corner -int 4
killall Dock

# Finder の設定
defaults write com.apple.finder AppleShowAllFiles true
defaults write com.apple.finder FXPreferredViewStyle Nlsv
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder _FXSortFoldersFirst -bool true
chflags nohidden ~/Library
killall Finder

# スクリーンショットの設定
# デフォルトディレクトリの変更
defaults write com.apple.screencapture location ~/Pictures/
# 影をつけない
defaults write com.apple.screencapture disable-shadow -boolean true
killall SystemUIServer

# ショートカット関連
# 全体 やり直し: cmd+Y 置換: cmd+H
defaults write "Apple Global Domain" NSUserKeyEquivalents -dict "\U3084\U308a\U76f4\U3057" "@y" "\U7f6e\U63db" "@h"

# Chrome 次を検索: F3 前を検索: shift+F3 デベロッパー ツール: F12 ソースを表示: cmd+U
defaults write com.google.Chrome NSUserKeyEquivalents -dict "\U30bd\U30fc\U30b9\U3092\U8868\U793a" "@u" "\U30c7\U30d9\U30ed\U30c3\U30d1\U30fc \U30c4\U30fc\U30eb" "\Uf70f" "\U524d\U3092\U691c\U7d22" "$\Uf706" "\U6b21\U3092\U691c\U7d22" "\Uf706"

# 変換切り替え cmd+space
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 60 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>32</integer><integer>49</integer><integer>1048576</integer></array><key>type</key><string>standard</string></dict></dict>"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 61 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>32</integer><integer>49</integer><integer>1310720</integer></array><key>type</key><string>standard</string></dict></dict>"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 64 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>32</integer><integer>49</integer><integer>524288</integer></array><key>type</key><string>standard</string></dict></dict>"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 65 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>65535</integer><integer>49</integer><integer>1572864</integer></array><key>type</key><string>standard</string></dict></dict>"

# Terminal
open "Pro custom.terminal"
defaults write com.apple.Terminal "Default Window Settings" -string "Pro custom"
defaults write com.apple.Terminal "Startup Window Settings" -string "Pro custom"

# HOME ENDキー、バックスラッシュ 円マークの挙動を変更
mkdir -p ~/Library/KeyBindings
cat << EOF > ~/Library/KeyBindings/DefaultKeyBinding.dict
{
    "\UF729"  = moveToBeginningOfLine:;
    "\UF72B"  = moveToEndOfLine:;
    "$\UF729" = moveToBeginningOfLineAndModifySelection:;
    "$\UF72B" = moveToEndOfLineAndModifySelection:;
    "@\UF729" = moveToBeginningOfDocument:;
    "@\UF72B" = moveToEndOfDocument:;
    "¥"       = ("insertText:", "\\\\");
    "_"       = ("insertText:", "\\\\");
    "\$_"      = ("insertText:", "_");
}
EOF

# その他の設定
# ネットワーク接続したディレクトリに.DS_Storeを作らない
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# タップをクリックに
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# バッテリーパーセント表示
defaults write com.apple.menuextra.battery ShowPercent -string "YES"

# Bash の設定
# https://qiita.com/2k0ri/items/9fe8d33a72dbfb15fe6b
cat << EOF > ~/.bash_profile
if [ "$TERM_PROGRAM" = "Apple_Terminal" ]; then
    if [ -f ~/.bashrc ]; then
        source ~/.bashrc
    fi
fi
EOF
cat << EOF > ~/.bashrc
HISTSIZE=1000
HISTFILESIZE=2000

alias ls="ls -G"
alias vi="vim"

export LSCOLORS=exgxcxdxcxegedabagacad

if [ $UID -eq 0 ]; then
    PS1="\[\033[31m\]\u@\h\[\033[00m\]:\[\033[01m\]\w\[\033[00m\]\\$ "
else
    PS1="\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[00m\]\[\033[01m\]\[\033[00m\]\\$ "
fi

brew-cask-upgrade(){
    for app in $(brew cask list);
    do local latest="$(brew cask info "${app}" | awk 'NR==1{print $2}')";
        local versions=($(ls -1 "/usr/local/Caskroom/${app}/.metadata/"));
        local current=$(echo ${versions} | awk '{print $NF}');
        if [[ "${latest}" = "latest" ]];
            then echo "[!] ${app}: ${current} == ${latest}";
            [[ "$1" = "-f" ]] && brew cask install "${app}" --force;
            continue;
        elif [[ "${current}" = "${latest}" ]];
            then continue;
        fi;
        echo "[+] ${app}: ${current} -> ${latest}";
        brew cask uninstall "${app}" --force;
        brew cask install "${app}";
    done;
}

[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
EOF
source ~/.bash_profile

以上是关于sh macOS Sierra自分なりの环境构筑スクリプト(通しで走らせたことがないので动くかは不明)的主要内容,如果未能解决你的问题,请参考以下文章

sh Ubuntu 16.10用オレオレ环境构筑スクリプト

sh 构筑后に降价形式でEC2のリソース情报を吐き出すスクリプト

sh OSX Sierra网络性能调整#macOS

sh 解决方法adb断开macOS Sierra上的问题

sh 在macOS Sierra上的virtualenv中安装psycopg2

sh macOS Sierra에서원화(₩)대신백쿼트(`)입력하기