èæ¯
æ°ãããã·ã³ãå°å ¥ãããã³ã«ã»ããã¢ããã«æéããããã®ã¯å¤§å¤ã§ãããã®ãããç§ã®å ´åã¯ã以ä¸ã®ããã« bootstrap.sh ã³ãã³ããå®è¡ããã ãã§ç°å¢æ§ç¯ãã§ããããã«ãã¦ãã¾ãã
bash -c "$(curl -L https://bitbucket.org/hkob/dotfiles/raw/HEAD/bootstrap.sh)"
ä»åãM1 ãã·ã³ãå ¥ã£ã¦ãã¦ããã®ã¾ã¾ã§ã¯ãã®ã¹ã¯ãªãããå©ç¨ã§ãã¾ãããããã§ãM1 MacBook Air ãã»ããã£ã³ã°ããªãããdotfiles ã®ãªãã¸ããªã綺éºã«ãã¦ãããã¨æãã¾ãããã®è¨äºã¯å¾ããé次修æ£ãã¦ããã¾ãã(12/17追è¨) å®éã«å®è¡ããã¨ãããããªãã®ä¿®æ£ãããã¾ããã bootstrap.sh の実行と修正 - M1 MacBook Air インストール覚書(12) - hkob’s blogã§ã¤ã³ã¹ãã¼ã«è¨é²ãæ¸ãã¦ãã¾ãããã¡ããåç §ãã¦ãã ããã
bootstrap.sh ã«ãããæ©ç¨®å¤å®ã®å°å ¥
ã¾ã ãM1 MacBook Air ãæ¥ãªãã®ã§ãããããããããæ
å ±ã§å¤æãã¦ãã¾ããã¨ãããã uname -m
ã§ã¢ã¼ããã¯ãã£ãåå¾ã§ãããããªã®ã§ãããRosetta2 ã§åä½ãã¦ããã¿ã¼ããã«ã§ã¯ãx86_64
ã帰ã£ã¦ãã¦ãã¾ãããã§ããããã§ãuname -m
ã®çµæã¨arch -arm64 uname -m
ã®çµæã使ããã¨ã§ãRosetta2 ä¸ã§å®è¡ããããã¨ã©ã¼ãåºãããã«ãã¦ã¿ããã¨æãã¾ããIntel Mac ã®å ´åã«ã¯ãarm64 ã¢ã¼ããã¯ãã£ããªãã®ã§ãx86_64-ãã¨ãªãã¾ãããã¤ãã£ãã¿ã¼ããã«ã§ã¯ããarm64-arm64ãã¨ããæãã«ãªãã¾ããRosetta2 ã®å ´åã ããx86_64-arm64ãã¨ããå½¢ã«ãªãã®ã§ããããå¤å®ããã° Rosetta2 ã®å ´åã ãä¾å¤å¦çãã§ããã¨èãã¦ãã¾ããã¾ããã¹ã¯ãªããã®ä¸ã§ M1 ãã©ãããå¤æãããã©ã°ã¨ãã¦ãis_arm ã¨ããé¢æ°ãå®è£
ãã¦ããã¾ã(ä¸ã®æ¹ã§ä½¿ãã¾ã)ã
ããã¾ã§ãè¸ã¾ãã¦ååé¨åã¯ãããªæãã«ãªãã¾ãããIntel Mac ã§ãã®é¨åãä½ããªãééãã¦ãããã¨ã確èªãã¾ãããM1 Air ãå±ããããã¾ãããã確èªãã¦ã¿ã¾ãã
#!/usr/bin/env bash # ã¨ã©ã¼ããã£ããããã§å³çµäºãè¨å®ãã¦ããªãå¤æ°ã使ã£ããã¨ã©ã¼ã«ãã set -eu # is_arm ã¨ããé¢æ°ãç¨æãã¦ãããæ¯å uname -m ãå®è¡ããã®ã¯è«è¿¦ãããã®ã§ãUNAME ç°å¢å¤æ°ã§å¤æ is_arm() { test "$UNAME" == "arm64"; } # ã¢ã¼ããã¯ãã£å㯠UNAME ã«å ¥ãã¦ãã UNAME=`uname -m` # dotfiles ã®å ´æãè¨å® DOTPATH=$HOME/dotfiles # Rosetta2 ã§ã¿ã¼ããã«ãåããã¦ããæã«ã¯å¼·å¶çµäºããã if [ "$UNAME-$(arch -arm64 uname -m)" == "x86_64-arm64" ]; then echo "This script can not exec in Rosetta2 terminal" exit 1 fi
(12/17ãarm64e ã¨ããæ å ±ãééã£ã¦ããã®ã§ãarm64 ã«ä¿®æ£)
defaults ç³»ã®è¨å®
ä¸åãããããªããã¨ãªã®ã§ããã¤ãæ¤ç´¢ããªããè¨å®ãã¦ãã¾ãããã©ããä¸åã ããããªãããã§è¨å®ãã¦ãã¾ããã¨ã«ãã¾ãã æãã¤ãããã®ã追è¨ãã¦ããã¾ããä¸ã¤ã¯ã¹ã¯ãªã¼ã³ã·ã§ããã®å½±ãå¤ãè¨å®ã§ãã ææ¥è³æã§ã¹ã¯ãªã¼ã³ã·ã§ãããå¤ç¨ããã®ã§ãå ¨ã¦ã®ãã·ã³ã§ãã¤ãè¨å®ãã¦ãã¾ããã
# ã¹ã¯ãªã¼ã³ã·ã§ããã«å½±ãã¤ããªãããã«ãã defaults write com.apple.screencapture disable-shadow -boolean true killall SystemUIServer
ã³ãã³ãã©ã¤ã³ãã¼ã«ã®èªåã¤ã³ã¹ãã¼ã«ããã³ Rosetta2 ã®ã¤ã³ã¹ãã¼ã«
ããã¾ã§ã³ãã³ãã©ã¤ã³ãã¼ã«ã¯äºåã¤ã³ã¹ãã¼ã«ãã¦ããã®ã§ããããããçµã¿å ¥ãã¦ãã¾ããã¨ãããã¨ã§ãgit ã³ãã³ãã®æç¡ã§ãã§ãã¯ãããã¨ã«ãã¾ãããgit ããªããã°ãã³ãã³ãã©ã¤ã³ãã¼ã«ãã¤ã³ã¹ãã¼ã«ãã¾ããã¤ã³ã¹ãã¼ã«ãå¾ ã¤ãã¨ã¯ã§ããªãã®ã§ãå度å®è¡ãã¦ãããããã«ä¿ãã¾ããM1 Mac ã®å ´åã«ã¯ãRosetta2 ãå¿ è¦ãªã®ã§ããã§ä¸ç·ã«ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ããã¨ã«ãã¾ãããããåæã«å®è¡ã§ãããã¯ãå®éã«ãã·ã³ãæ¥ã¦ã¿ãªãã¨ãããã¾ããã
# git ãå ¥ã£ã¦ããªããã°ãã³ãã³ãã©ã¤ã³ãã¼ã«ãã¤ã³ã¹ãã¼ã« if ! command -v git > /dev/null 2>&1; then echo "Installing Command line tools ..." xcode-select --install # ãã®å ´åãM1 Mac ã§ã¯ Rosetta2 ãã¤ã³ã¹ãã¼ã«ããã¦ããªãã¨æãããã®ã§ããã¡ããã¤ã³ã¹ãã¼ã« if is_arm; then # ã½ããã¦ã§ã¢ã¢ãããã¼ã㧠Rosetta2 ãã¤ã³ã¹ãã¼ã«ãé¢åãªã®ã§ã©ã¤ã»ã³ã¹ç¢ºèªã¯ãªãã¯ãã¹ããã echo "Installing Rosetta2 ..." /usr/sbin/softwareupdate --install-rosetta --agree-to-license fi echo "Plaese exec ./bootstrap.sh again in $DOTPATH after installing command-line-tools and Rosetta2(M1 Mac only)." exit 1 fi
ãªãã¸ããªã¢ãããã¼ãã®éå®å®è¡
ããã¾ã§ãªãã¸ããªã¯å¼·å¶çã«ãªãã¸ããªã®ãã®ã«ã¢ãããã¼ãããããã«ãã¦ãã¾ããããã ããã¹ããã¦ãã¦ãã¡ã¤ã«ãæ¸ãæãã¦ããæã« git stash ããã¦æ³£ãããã¨ããããããã£ãã®ã§ãã¢ãããã¼ãå¦çã¯å¼æ°ãä»ããæã®ã¿å®è¡ããããã«ãã¾ãããã¢ãããã¼ããããæã¯./bootstrap.sh update
ã¨ãããã¨ã§å
é¨ã綺éºã«ããä¸ã§ããªãã¸ããªãææ°çã«æ´æ°ãã¾ãã
# ãã®ãã©ã«ãã®åãæ±ã if [ ! -d "$DOTPATH" ]; then # ååå®è¡æã¯ãªãã¸ããªããªãã®ã§ãclone ãã¦ãã echo "Cloning dotfiles.git ..." git clone https://[email protected]/hkob/dotfiles.git "$DOTPATH" else # ãã§ã«ãã©ã«ããããæã¯ãã®ãã¨ã表示 echo "$DOTPATH already downloaded." # å¼æ°ã« update ãä»ããå ´åã«ã¯ãå é¨ããããã«ã㦠pull ãã¦ãã if [ "X$*" == "Xupdate" ]; then # å é¨ã§æ¸ãæãããã®ã¯å»æ£ãã¦ããªãã¸ããªã®ææ°çã«å·®ãæ¿ãã echo "Update dotfiles.git ..." cd "$DOTPATH" git stash git checkout master git pull origin master echo fi fi
dotfiles ã®å±é
ããã¾ã§ãscripts/deploy.sh ã«åé¢ãã¦ãã¾ããããè¦éããæªãã®ã§ããã«åè¨ãããã¨ã«ãã¾ãããã¤ã³ã¹ãã¼ã«ãªã©ã§åç §ããå¯è½æ§ãããã®ã§ãXDG_CONFIG_HOME 㯠bootstrap.sh å ã«ãå®ç¾©ãã¦ããããã§ã(ãã£ããå¿ãã¦ãã¾ãã)ãXDG_CONFIG_HOME ã«ã¤ãã¦ã¯ArchWiki の XDG Base Directoryã«è©³ããæ¸ãã¦ããããã§ãã
# ããã«ãã dotfiles ããã¼ã ã«å±é (.git, .DS_Store ã¯é¤å¤ãä»ã«é¤å¤ãããã®ãå¢ãããããã«è¿½è¨) echo "Deploying dotfiles ..." for file in .??*; do [[ "$file" = ".git" ]] && continue [[ "$file" = ".DS_Store" ]] && continue ln -fvns "$DOTPATH/$file" "$HOME/$file" done # ã©ã®ãããã®ã¢ããªã使ããããããªãããXDG_CONFIG_HOME ã®ç°å¢å¤æ°ã¯å®ç¾©ãã¦ãã # [[ -z $XDG_CONFIG_HOME ]] && XDG_CONFIG_HOME=$HOME/.config # mkdir -p "$XDG_CONFIG_HOME" # echo
(12/17追è¨) XDG_CONFIG_HOME ã¯ããã©ã«ã㧠$HOME/.config ã«ãªãã®ã§ãããããè¨å®ããå¿ è¦ã¯ãªãã¨ã®ãã¨ã§ããããã®é¨åã¯åé¤ãã¾ããã
homebrew ã·ã¹ãã ã®ã¤ã³ã¹ãã¼ã«
Homebrew 㯠Intel Mac 㨠Rosetta2 ç°å¢ã®ãã®ã¯ /usr/local/bin ã«ã¤ã³ã¹ãã¼ã«ããã¾ããHomebrew æ¬å®¶ãç´¹ä»ãã¦ããããã« M1 native ã®ãã®ã¯ã/opt/homebrew ã«å¥éã¤ã³ã¹ãã¼ã«ãããã¨ã«ãã¾ããä»å¾ãåºæ¬çã«ã¯ãã¤ãã£ãçã§ã¤ã³ã¹ãã¼ã«ããã¤ã³ã¹ãã¼ã«ã§ããªãã£ãå ´åã«ã¯ Rosetta2 çã§ã¤ã³ã¹ãã¼ã«ãããã¨ã«ãã¾ããããã§æ¯åãã¹ãæ¸ãã®ã¯é¢åãªã®ã§ãRosetta2 çã® brew 㯠brew_x86 ã¨ããååã§å®è¡ã§ããããã«ãã¦ããã¾ãããã®ããããã¡ããã¨åããã©ããã¯ãAir ãå±ãã¦ãã確èªãã¾ãã
# install homebrew if ! command -v brew > /dev/null 2>&1; then # Install homebrew in Intel Mac or M1 Mac on Rosetta2 echo "Installing homebrew in /usr/local for Intel or Rosetta2 ..." arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo # M1 Mac ã§ã¯ /opt/homebrew ã«ãã¤ãã£ãçãã¤ã³ã¹ãã¼ã« if is_arm; then echo "Installing homebrew in /opt/homebrew for Arm ..." cd /opt sudo mkdir homebrew sudo chown $USER:admin homebrew curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew # M1 ã®å ´åã«ã¯ãRosetta2 çã® brew ã brew_x86 ã¨ããååã§å®è¡ã§ããããã«ãã¦ãã cd /usr/local/bin ln -s /usr/local/Homebrew/bin brew_x86 # ãã®é çªã§ããã¨ãPATH 㯠ã/opt/homebrew/bin:/usr/local/bin:ãã以å¤ãã«ãªããã¨ãæå¾ ãã¦ãããããã¯å®è¡ãã¦ã¿ãªãã¨ããããªã fi fi
(12/17追è¨: brew_x86 ã®ãªã³ã¯ã¯ãªãªã¸ãã«ã® /usr/local/Homebrew/bin ã«å¼µããªãã¨åããªãã£ãããä¿®æ£ãã¾ãã)
Homebrew èªä½ã®ã¤ã³ã¹ãã¼ã«
å®éã®ã¢ããªã¯ brew bundle
ã§ä¸æ¬ã¤ã³ã¹ãã¼ã«ãã¾ãããã·ã³ãã¨ã«ã¤ã³ã¹ãã¼ã«ã§ãããã®ãç°ãªãã®ã§ä»¥ä¸ã®ãã©ã«ãã« Brewfile ãåãã¦è¨è¿°ãããã¨ã«ãã¾ããã
- arm_brew/Brewfile: M1 native ã®ã¢ããª
- rosetta2_brew/Brewfile: Rosetta2 ã§ããåä½ããªãã¢ããª
- intel_brew/Brewfile: Intel Mac ã®ã¢ããª
ã¾ããç¾å¨ã® Brewfile ã intel_brew/Brewfile ã«ç§»åãã¾ããM1 Mac ã®æ¹ã§ã¯ã¢ããªã®æ¤è¨¼ãããä¸ã§ arm_brew/Brewfile ã¾ã㯠rosetta2_brew/Brewfile ã«æ¯ãåãã¦ããã¾ããApp Store ã®ã¢ããªã¯ masãGUI ã¢ããªã¯ brew cask ã§ã¤ã³ã¹ãã¼ã«ãã¾ããããã㯠arm_brew/Brewfile ã®æ¹ã«è¨è¼ãã¦ããã°è¯ãã¨æãã¾ãããããã®æ¯ãåãã«ã¤ãã¦ã¯ããã®è¨äºã§èª¬æãã¦ããã¾ãã
# homebrew and cask if is_arm; then echo "brew bundle in Arm native ..." cd arm_brew brew bundle echo "brew bundle in Rosetta2 ..." cd ../rosetta2_brew brew bundle cd .. else echo "brew bundle in Intel ..." cd intel_brew brew bundle cd .. fi echo
(12/17追è¨) ã³ã¡ã³ããéã«ãªã£ã¦ããã®ã§ä¿®æ£ãã¾ããã
config ã®å¾©å
mackup ã«ãã config ã¯æ©ç¨®ä¾åããªãã¨æãã®ã§ããã®ã¾ã¾ã«ãã¦ããã¾ãã
# config ã®å ±æã®å¾©å echo "Restoring config files by mackup ..." mackup restore echo
MacTeX ã®ç°å¢è¨å®
ããã¾ã§é å¼µã£ã¦ãã©ã®ããã©ã³ãã PDF ã«åãè¾¼ãããã«è¨å®ãã¦ãã¾ãããããããTeX Live 2020 ã§ããã©ã«ãã§è¨å®ããããåã®å³ãã©ã³ãããããªããããªã£ã¦ããã®ã§ãç¡çããªããã¨ã«ãã¾ããããã®ãããTeX Live ãã¢ãããã¼ãã ãã®å¦çã«ãªã£ã¦ãã¾ãã
# MacTeX (TeX Live) ã®ã¢ãããã¼ã echo "Updating TeX Live library ..." TLMGR_REPOSITORY=http://ftp.jaist.ac.jp/pub/CTAN/systems/texlive/tlnet sudo tlmgr option repository $TLMGR_REPOSITORY sudo tlmgr update --self --all --no-persistent-download
Ruby ã®ã¤ã³ã¹ãã¼ã«
Ruby 㯠rbenv ã§ææ°çãã¤ã³ã¹ãã¼ã«ãã¾ããã¤ã³ã¹ãã¼ã«ããã¦ããªããã°ãã¤ã³ã¹ãã¼ã«ããããã«ãªã£ã¦ãã¾ãããã®æãopenssl 㯠homebrew ã§ã¤ã³ã¹ãã¼ã«ãããã®ã使ãããã«ãã¦ãã¾ãã
# Ruby ã®ã¢ãããã¼ã RBENV_VERSION=2.7.2 RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" now_rbenv=$(rbenv version | awk '{print $1}') if [ "X${now_rbenv}" != "X${RBENV_VERSION}" ]; then echo "Installing ruby ..." rbenv install $RBENV_VERSION rbenv global $RBENV_VERSION fi
çµäº
æå¾ã« Bootstrapping DONE ã表示ããã¦ããã¾ãã§ãã
echo "Bootstrapping DONE!"
ãã¦ãããã M1 Mac ã§åä½ãããã¯ãå±ãã¦ããã®ã楽ãã¿ã
次ã®è¨äº: Big Sur の環境設定(1段目) - M1 MacBook Air インストール覚書(4) - hkob’s blog åã®è¨äº: 既存環境の環境変更 - M1 MacBook Air インストール覚書(2) - hkob’s blog