アプリインストール(Alfred, Visual Studio Code - Insiders, mackup) - M1 MacBook Air インストール覚書(15)

はじめに

途中までこの記事を書いていたのですが、バッテリーなくなるまで書いてみようと思ったら、バッテリーが尽きた時にスリープせずに落ちました。M1 Mac の噂では聞いていましたが、スリープになることを期待するのは危険かもしれません。とりあえず書いたものを思い出しながら書いてみます。ちなみに、以下のグラフは今日のバッテリー状況です。インストール作業はディスクアクセスがかなり大きいので、流石に厳しかったですね。ただ、Intel Mac で同じ作業をしていたら 2〜3 時間くらいでバッテリ切れしていたと思われるので、普段使いなら十分バッテリは持ちそうです。

f:id:hkob:20201217180039p:plain
バッテリー

ここからまたしばらくアプリインストールが続くので、TeX Live update の前に exit を入れておくことにしました。ここから cask 系のものをまとめてインストールしていきます。

Alfred 4 (arm_brew)

アプリの起動などに Alfred 4 を使いまくっているので、やはり先にインストールしておくべきだと思いました。

cask "alfred"

インストールされたものを確認しましたが、さすが Universal binary です。

f:id:hkob:20201217180919p:plain
Alfred 4 info

Gettting Started の画面です。初期設定でいくつか実施項目があります。

f:id:hkob:20201217181013p:plain
Alfred 4 Getting Started

PowerPack の Legendary Supporter になっているので、PowerPack を有効化しておきました。

f:id:hkob:20201217181608p:plain
PowerPack の有効化

また、ファイルや連絡先などにアクセスするので、macOS のパーミッション設定が必要になります。

f:id:hkob:20201217182006p:plain
macOS Permisson の設定

アクセシビリティ、フルディスクアクセス、連絡先に Alfred 4 を追加します。フルディスクアクセスだけは Alfred 4 が表示されていなかったので、「+」を使って手動で登録しました。

f:id:hkob:20201217182243p:plainf:id:hkob:20201217182436p:plainf:id:hkob:20201217183014p:plain
macOS Permisson の設定画面

Preferences については、また後で設定します。

Visual Studio Code (arm_brew)

とりあえず、今は vi を使っていますが最近はすっかり Visual Studio Code を使っているので、これも早めにインストールしてみます。 とりあえず Intel 版でいいかと思っていたのですが、今日、Microsoft、Visual Studio CodeをM1 Macに最適化 - ITmedia NEWSという記事を見つけました。"homebrew/cask-versions" に入っている visual-studio-code-insiders は Intel 版の cask なので、これを元に野良 cask を作ってみます。Electron が 11 の間は Universal binary ではなく、Intel 版と Apple シリコン版が別々に用意されるようです。

とりあえず、記事で紹介されているInsider のページにアクセスしてみます。ARM64 をクリックするとアプリがダウンロードフォルダに入りました。ゴミ箱を確認すると展開前の zip ファイルがありました。ダウンロードフォルダに戻して情報を見ると、zip ファイルの URL が書かれていました。

この情報を元に野良 cask を作ります。とりあえず、前回作成した自作の tap を取り入れます。以下の行を追加し、bootstrap.sh を実行すると tap が入りました。

tap "hkob/m1-beta-cask"

先ほど入手した URL から野良 cask を作成します。

hkob@hM1Air dotfiles % brew create --cask --set-name visual-studio-code-insiders-arm64 https://az764295.vo.msecnd.net/insider/c8aaeb75137b8ec057d2676a22f7273a7a6a34a2/VSCode-darwin-arm64.zip
==> Downloading https://az764295.vo.msecnd.net/insider/c8aaeb75137b8ec057d2676a2
######################################################################## 100.0%
Please run `brew audit --cask --new visual-studio-code-insiders-arm64` before submitting, thanks.
Editing /opt/homebrew/Library/Taps/homebrew/homebrew-cask/Casks/visual-studio-code-insiders-arm64.rb
Warning: Using vim because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.

homebrew-cask に作成されてしまっているので、m1-beta-cask に移動します。

mv /opt/homebrew/Library/Taps/{homebrew/homebrew-cask/Casks/visual-studio-code-insiders-arm64.rb,hkob/homebrew-m1-beta-cask/Casks}

あとは、Intel 版の visual-studio-code-insiders cask と比較して修正します。最終的にこんな感じになりました。

cask "visual-studio-code-insiders-arm64" do
  version "1.53.0,c8aaeb75137b8ec057d2676a22f7273a7a6a34a2"
  sha256 "afd65945c9df01e195e075d314e07eb81ee557afb0a30e56ea30a894243f7b26"

  url "https://az764295.vo.msecnd.net/insider/#{version.after_comma}/VSCode-darwin-arm64.zip",
      verified: "az764295.vo.msecnd.net/insider/"
  appcast "https://vscode-update.azurewebsites.net/api/update/darwin/insider/VERSION"

  name "VS Code - Insiders"
  desc "Integrated development environment"
  homepage "https://code.visualstudio.com/insiders"

  app "Visual Studio Code - Insiders.app"
  binary "#{appdir}/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", target: "code-insiders"

  zap trash: [
    "~/Library/Application Support/Code - Insiders",
    "~/Library/Caches/Code - Insiders",
    "~/Library/Caches/com.microsoft.VSCodeInsiders",
    "~/Library/Caches/com.microsoft.VSCodeInsiders.ShipIt",
    "~/Library/Preferences/com.microsoft.VSCodeInsiders.helper.plist",
    "~/Library/Preferences/com.microsoft.VSCodeInsiders.plist",
  ]
end

最後に、arm_brew/Brewfile に cask を追加して、bootstrap.sh を実行します。

cask "visual-studio-code-insiders-arm64"

アプリケーションフォルダにインストールされた Visual Studio Code - Insiders を確認すると Apple シリコン版になっていました。正式版が Apple シリコンに対応したら、正式版の cask に作り替えようと思います。

f:id:hkob:20201217213116p:plain
Visual Studio Code - Insiders info

とりあえず Slack などの Electron アプリはしばらく同じ対応が必要かもしれませんね。

mackup (arm_brew)

Visual Studio Code などの設定は mackup で複数のマシンで共有していました。

brew "mackup", args: ["build-from-source"]

bootstrap.sh の下の方で mackup restore をやっていますが、ここでは手動でリストアしておきます。.ssh/config や .config/fish/config.fish が同期すると楽でよいです。当初、dotfiles の方がリポジトリ管理できるのは便利なのですが、どうしてもリアルタイム性にかけてしまいます。あまり差分が重要でないものは、mackup で管理するようになってしまいました。

hkob@hM1Air dotfiles % mackup restore
Restoring .config/fish/functions ...
Restoring .config/fish/config.fish ...
Restoring .config/fish/fish_variables ...
Restoring .ssh/config ...
Restoring .ssh/authorized_keys ...
Restoring Library/Application Support/Code/User/keybindings.json ...
Restoring Library/Application Support/Code/User/settings.json ...
Restoring Library/Application Support/Code/User/snippets ...

これで設定が同期するかと思いましたが、Visual Studio Code - Insiders は設定ファイルの保存場所が違いました。この部分は手作業で Code のものをシンボリックリンクで参照しました。

lrwxr-xr-x  1 hkob  staff   32 12 17 21:59 keybindings.json -> ../../Code/User/keybindings.json
lrwxr-xr-x  1 hkob  staff   29 12 17 21:58 settings.json -> ../../Code/User/settings.json
lrwxr-xr-x  1 hkob  staff   24 12 17 21:59 snippets -> ../../Code/User/snippets

これで VIsual Studio Code - Insiders が同じ設定で開きました。

次の記事 アプリインストール(Slack) - M1 MacBook Air インストール覚書(16) - hkob’s blog

前の記事 アプリインストール(Xquartz, Google Chrome, MacTeX) - M1 MacBook Air インストール覚書(14) - hkob’s blog

hkob.hatenablog.com