LoginSignup
213
134

More than 3 years have passed since last update.

Finder のコンテキストメニューに「Visual Studio Code で開く」を追加する

Last updated at Posted at 2018-06-28

Finderのコンテキストメニューに「Visual Studio Codeで開く」を追加することで、Finderから編集したいフォルダやファイルを指定するだけでVS Codeで編集できるようになるので非常に便利です。

WindowsのSakuraエディタといったエディタでは、インストール時に右クリックメニューに追加する設定ができるので、非常に重宝していましたが、MacでVSCodeを使い始めたときに同様のことはできないのかと思い調べてみました。

macOS Catalinaからzshに変更されたので追記しました。

Automatorで作成

AutomatorはmacOSの自動化ユーティリティです。

  1. Automatorを開く
    このアイコンが目印です。
    スクリーンショット 2019-12-31 23.06.24.png

  2. メニュー > ファイル > 新規 を選択する

  3. テンプレート(書類の種類)は「クイックアクション」を選択します。
    スクリーンショット 2019-12-31 23.07.02.png

アクションの追加

左側のライブラリ列は

「ユーティリティ」を選択

中央のアクション列は

「シェルスクリプトを実行」を選択し、ワークフローパネルにドラッグします。

右上の”サービス”は、次の選択項目を受け取るポップアップメニューは

”サービス”は、次の選択項目を受け取る:ファイルまたはフォルダ
検索対象:Finder.app

ワークフローパネルは

シェル: /bin/zsh (macOS 10.14以下は /bin/bash)
入力の引き渡し方法:引数として

入力欄には下記のコードを記述します。

for f in "$@"
do
    open -a 'Visual Studio Code' "$f"
done

スクリーンショット 2019-12-31 23.09.21.png

ワークフローを保存する

  1. メニュー > 保存
  2. 保存名を「Visual Studio Codeで開く」としてください。

「Visual Studio Codeで開く.workflow」として保存されます。

スクリーンショット 2019-12-31 23.09.31.png

確認

Finder > コンテキストメニュー > サービス

を見ると「Visual Studio Codeで開く」メニューが追加されていることを確認してください。

スクリーンショット 2019-12-31 23.10.01.png

参考

macos - OSX: how to add a right click option in folder to open the folder with an application like VS Code? - Ask Different

Mac 101:Automator - Apple サポート

213
134
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
213
134