<html> <hr/> ↓古いコードが折り畳まれている <details> <pre> # For Mac with M1 processor
TARGET_PACKAGES=(wget emacs gcc) CHECKED_PACKAGES=(${TARGET_PACKAGES} gfortran) check_flag=1
## Install Homebrew which brew >/dev/null 2>/dev/null if [ $? -ne 0 ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ "$(uname -a | sed 's/ /\n/g' | tail -n1)" = "arm64" ]; then
echo 'if [ "$(uname -a | sed '\''s/ /\n/g'\'' | tail -n1)" = "arm64" ]; then' >> /Users/$USER/.zprofile
echo ' eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile
echo 'fi' >> /Users/$USER/.zprofile
source /Users/$USER/.zprofile
fi
fi
## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then
echo "Homebrew is not installed." 1>&2 exit 1
fi
bash “$(dirname $0)/setup_homebrew_install_packages.sh”
#### code #### bash setup_homebrew_install_packages.sh
# For Homebrew
GCC_VERSION=“10”
TARGET_PACKAGES=(wget emacs gcc@${GCC_VERSION}) CHECKED_PACKAGES=(wget emacs gcc gfortran) check_flag=1
## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then
echo "Homebrew is not installed." 1>&2 exit 1
fi
BREW_ROOT=`brew –prefix`
## Install each package echo “Install packages” for package in ${TARGET_PACKAGES[@]}; do
echo ${package}
done for package in ${TARGET_PACKAGES[@]}; do
brew install ${package}
done
## Use GCC instead of Clang if ! [ -f “${BREW_ROOT}/bin/gcc” ]; then
ln -s ${BREW_ROOT}/bin/gcc-${GCC_VERSION} ${BREW_ROOT}/bin/gcc
if [ $? -ne 0 ]; then
echo "Symbolic link of GCC cannot be created." 1>&2
exit 1
fi
fi if [ “`readlink ${BREW_ROOT}/bin/gcc`" != "${BREW_ROOT}/bin/gcc-${GCC_VERSION}” ]; then
echo "gcc command may use Clang or default GCC instead of GCC installed by Homebrew." 1>&2
fi
## Check whether each packages is installed or not. echo “” echo “” echo “Check packages” for package in ${CHECKED_PACKAGES[@]}; do
${package} --version >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo "${package} is not installed." 1>&2
check_flag=0
fi
done
echo “” if [ ${check_flag} -eq 1 ]; then
echo "Completed!"
else
echo "Some packages are not installed correctly."
fi </pre> </details> <hr/> </html>
# For Mac with M1 processor ## Install Homebrew which brew >/dev/null 2>/dev/null if [ $? -ne 0 ]; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if [ "$(uname -a | sed 's/ /\n/g' | tail -n1)" = "arm64" ]; then echo 'if [ "$(uname -a | sed '\''s/ /\n/g'\'' | tail -n1)" = "arm64" ]; then' >> /Users/$USER/.zprofile echo ' eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile echo 'fi' >> /Users/$USER/.zprofile source /Users/$USER/.zprofile fi fi ## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then echo "Homebrew is not installed." 1>&2 exit 1 fi # For Homebrew GCC_VERSION="11" TARGET_PACKAGES=(wget emacs gcc@${GCC_VERSION}) CHECKED_PACKAGES=(wget emacs gcc gfortran) check_flag=1 ## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then echo "Homebrew is not installed." 1>&2 exit 1 fi BREW_ROOT=`brew --prefix` ## Install each package echo "Install packages" for package in ${TARGET_PACKAGES[@]}; do echo ${package} done for package in ${TARGET_PACKAGES[@]}; do brew install ${package} done ## Use GCC instead of Clang if [ -f "${BREW_ROOT}/bin/gcc" ]; then rm "${BREW_ROOT}/bin/gcc" fi ln -s ${BREW_ROOT}/bin/gcc-${GCC_VERSION} ${BREW_ROOT}/bin/gcc if [ $? -ne 0 ]; then echo "Symbolic link of GCC cannot be created." 1>&2 exit 1 fi if [ "`readlink ${BREW_ROOT}/bin/gcc`" != "${BREW_ROOT}/bin/gcc-${GCC_VERSION}" ]; then echo "gcc command may use Clang or default GCC instead of GCC installed by Homebrew." 1>&2 fi ## Check whether each packages is installed or not. echo "" echo "" echo "Check packages" for package in ${CHECKED_PACKAGES[@]}; do ${package} --version >/dev/null 2>/dev/null if [ $? -ne 0 ]; then echo "${package} is not installed." 1>&2 check_flag=0 fi done echo "" if [ ${check_flag} -eq 1 ]; then echo "Completed!" else echo "Some packages are not installed correctly." fi
defaults write com.apple.inputmethod.Kotoeri JIMPrefLiveConversionKey -bool false
defaults delete com.apple.inputmethod.Kotoeri JIMPrefLiveConversionKey
カーソルキーで移動するときにつらいのでキーのリピート入力の速度を上げたほうが良い。
defaults write -g InitialKeyRepeat -int 15 defaults write -g KeyRepeat -int 2
defaults write com.apple.dock autohide -bool true
defaults delete com.apple.dock autohide
defaults でやるのは難しそう。
ゴミ箱の削除とか、そういうことが初期設定ではできないので、設定を変更する必要がある。
環境設定 → セキュリティとプライバシー → プライバシー → フルディスクアクセス
ターミナルのチェックを入れる。
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.finder AppleShowAllFiles -bool true
環境設定 → Bluetooth → メニューバーにBluetoothを表示
環境設定 → Dockとメニューバー → バッテリー → 割合(%)を表示
環境設定 → 日付と時刻 → 時間帯
環境設定 → サウンド → メニューバーにサウンドを表示 「常に」
環境設定 → トラックパッド → 「ポイントとクリック」 → 「タップでクリック」
defaults read > hoge.txt defaults -currentHost read > foo.txt
GUI で設定変更してみる
defaults read > fuga.txt defaults -currentHost read > bar.txt
まずは差分を見る。
diff hoge.txt fuga.txt diff foo.txt bar.txt
それっぽい単語のありそうな箇所の行番号をみる。
cat fuga.txt | grep -n 単語
近傍を確認すると、名前空間がわかるはず。(例は123行目から456行目までを表示)
cat fuga.txt | sed -n '123,456p'
以下のコマンドを実行すれば設定変更ができるんだなと言うことがわかる。
defaults write com.apple.piyopiyo bazbaz -bool true
ただし反映には以下みたいにその機能を担当しているプログラムを再起動しなくてはいけない。
killall 何らかのプログラム
デフォルト設定に戻すには delete するだけ。
defaults delete com.apple.piyopiyo bazbaz
名前空間が Apple Global Domain のときだけ defaults コマンドに -g オプションが必要。
CUI を動かすためには CommandLineTools が必要。 これは2通りのインストール方法があるっぽい。
色つけ。bash の force_color_prompt と同じにしておく
PROMPT='%F{34}%n@%m%f:%F{32}%~%f$ ' export LSCOLORS=gxfxcxdxbxegedabagacad alias ll='ls -LGF' alias ls='ls -GF'
色を反映させるには次のようにする。
set-option -g default-terminal screen-256color set -g terminal-overrides 'xterm:colors=256'
デフォルトでは .bashrc を読んでくれないので以下のように .bash_profile を作るのが良い.← bashデフォルト時代の話?
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
homebrewは外部のリポジトリからもパッケージのインストールができるようになっている. caskはデスクトップアプリなどが豊富なリポジトリ. homebrew本家に吸収された.
# 更新情報の取得 (=apt update) brew outdated # 更新情報の取得 (=apt upgrade) brew update # パッケージを探す brew search <text> # パッケージをインストールする brew install <text> # インストールしたパッケージのアップデート brew upgrade # パッケージのアンインストール brew uninstall <text> # インストールしたパッケージ(=formula)の一覧 brew list brew list --versions # 古くなったパッケージの削除 brew cleanup
アンインストール
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
brew tapbrew tap hogebrew untap hogeこのようにインストールする
brew install hogehoge --cask
以下リスト
brew install visual-studio-code --cask brew install google-chrome --cask brew install firefox --cask
brew install microsoft-powerpoint --cask brew install microsoft-excel --cask brew install microsoft-word --cask
brew install google-drive --cask
brew install zoom --cask
sudo rm -rf /Applications/Google\ Chrome.app
して再インストールしたほうが良さそう。内部からアップデート適用するよりもクリーンな状態に保てる。
I edited file /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/openblas.rb
and added "NO_AVX512=1" in line 43 to
system "make", "CC=#{ENV.cc}", "FC=gfortran", "libs", "netlib", "shared", "NO_AVX512=1"
Then reinstalling openblas.
従来通り pyenv で処理系も切り替えできるようにしたい。 Anaconda, Miniconda は M1 mac では pyenv からは入れられない。 同じようなものに Miniforge というのがあるのでこちらを使うのが良い。
ただし python3 のバージョンは最低で 3.8 っぽい?(python3.6環境の構築は難しそう)
git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc source ~/.zshrc
pyenv install --list | grep miniforge pyenv install miniforge3-4.10.1-5 pyenv global miniforge3-4.10.1-5 echo '. /home/horiuchi/.pyenv/versions/miniforge3-4.10.1-5/etc/profile.d/conda.sh' >> ~/.zshrc source ~/.zshrc
Xcode 付属のものは
xcodebuild -version
でエラー無く実行可能。
単体のものは
'xcodebuild' requires Xcode
エラーが出る。
Monterey と Big Sur をデュアルブートしてみる。
M1 mac は出荷時の OS に復元することはできない。
インストールメディアを作成してダウングレードすることしかできない。
/Applications/Install macOS Big Sur.app があるはず。ls -la /Volumessudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia \
--volume /Volumes/USB_exFAT