ドットファイル以外を検索
televisionをインストール
以下のコマンドを実行してtelevisionをインストールします。
brew install television
タスクを追加する
tasks.json
に以下の記述を追加します。
tasks.json
{
"label": "File Finder",
"command": "zed \"$(tv files)\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},
キーバインドを追加する
キーバインドで先ほどのタスクを実行できるようにするためにkeymap.json
に以下を追記します。
keymap.json
"bindings": {
"cmd-p": [
"task::Spawn",
{ "task_name": "File Finder", "reveal_target": "center" }
]
}
参考
ドットファイルを含めて検索
televisionをインストール
以下のコマンドを実行してtelevisionをインストールします。
brew install television
ripgrepをインストール
以下のコマンドを実行してripgrepをインストールします。
brew install ripgrep
batをインストール
以下のコマンドを実行してbatをインストールします。
brew install bat
タスクを追加する
tasks.json
に以下の記述を追加します。
tasks.json
{
"label": "File Finder",
"command": "zed \"$(rg --files -uu --ignore-file='.zed/.ignore' 2> /dev/null | tv --preview 'bat -n -f -r:100 \"{0}\"')\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},
.ignore
を作成する
検索に含めたくないファイルを無視するために.zed/.ignore
ファイルを作成します。
.ignore
.git
.DS_Store
node_modules
キーバインドを追加する
キーバインドで先ほどのタスクを実行できるようにするためにkeymap.json
に以下を追記します。
keymap.json
// contextは任意の値
"bindings": {
"cmd-p": [
"task::Spawn",
{ "task_name": "File Finder", "reveal_target": "center" }
]
}
televisionの代わりにfzfを使う
televisionではなくfzfを使用しても同様の機能を実現できます。
fzfをインストールします。
brew install fzf
fzfを使用する場合はタスクは以下のようになります。
tasks.json
{
"label": "File Finder",
"command": "zed \"$(rg --files -uu --ignore-file='.zed/.ignore' 2> /dev/null | fzf --preview='bat -n -f -r:100 {}')\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},
他はtelevisionを使用する場合と同様です。
ripgrepの代わりにfdを使用する
ripgrepではなく、fdを使用する場合には以下のようになります。
fdをインストールします。
brew install fd
タスクを以下のように変更します。
tasks.json
{
"label": "File Finder",
"command": "zed \"$(fd -t f -u --ignore-file '.zed/.ignore' | fzf --preview='bat -n -f -r:100 {}')\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},