目次
- ブラウザー
- ファイラー
- エディタ
-
-
-
コマンド結果をフィルタリングしてくれます。
previewできるのが特徴です。
sudo apt install fzf
export FZF_DEFAULT_OPTS=" --height=60% --layout=reverse --border=rounded --info=inline-right --cycle " export FZF_DEFAULT_OPTS=" --height=60% --layout=reverse --border=rounded --info=inline-right --prompt='❯ ' --pointer='▶' --marker='✓' --cycle --scrollbar='│' " export FZF_DEFAULT_OPTS="--no-sort --exact --cycle --multi --ansi --reverse --border --sync --bind=ctrl-t:toggle" export FZF_DEFAULT_OPTS="--no-sort --exact --cycle --multi --ansi --reverse --border --sync --bind=ctrl-t:toggle --bind=ctrl-k:kill-line --bind=?:toggle-preview --bind=down:preview-down --bind=up:preview-up"
##$PROFLEファイルの確認
$PROFLE
##$PROFILEファイルがなかったら、作成
if (-not (Test-Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
##設定の修正
notepad $PROFILE
$env:FZF_DEFAULT_OPTS = @"
--height=60%
--layout=reverse
--border=rounded
--info=inline-right
--prompt="> "
--pointer=">"
--marker="*"
--cycle
--scrollbar="|"
"@
##設定の読み込み
. $PROFILE
vim $(fzf) vim $(find .|fzf)
~/.fzf_bookmarks というテキストファイルにお気に入りのパス(/path/to/dir)を改行区切りで保存しておき、以下の関数を .zshrc に記述します。
function cdmark() {
local dir=$(cat ~/.fzf_bookmarks | fzf)
[ -n "$dir" ] && cd "$dir"
}
function cdmark {
$dir = Get-Content "$HOME\.fzf_bookmarks" |
Where-Object { $_.Trim() -ne "" } |
fzf --prompt="Directory> "
if (-not $dir) {
return
}
if (Test-Path -LiteralPath $dir -PathType Container) {
Set-Location -LiteralPath $dir
}
else {
Write-Warning "ディレクトリが存在しません: $dir"
}
}
function addmark {
$bookmarkFile = "$HOME\.fzf_bookmarks"
$path = (Get-Location).Path
$bookmarks = @()
if (Test-Path -LiteralPath $bookmarkFile) {
$bookmarks = Get-Content -LiteralPath $bookmarkFile
}
if ($bookmarks -contains $path) {
Write-Host "すでに登録されています: $path"
return
}
Add-Content -LiteralPath $bookmarkFile -Value $path
Write-Host "ブックマークへ追加しました: $path"
}
# プロファイルの場所を確認 $PROFILE # プロファイルを開きます。 notepad $PROFILE # ファイルが存在しない場合は、先に作成します。 New-Item -ItemType File -Path $PROFILE -Force notepad $PROFILE # 関数を設定 #現在のPowerShellですぐ反映する . $PROFILE
導入方法:Homebrew 等で zoxide と fzf をインストールします。
使い方:
ターミナルで zi コマンドを叩くだけ。
過去の移動履歴や登録したお気に入りを fzf で絞り込んで即座に cd できます。
function ssh-fzf () {
local selected_host=$(grep "Host " ~/.ssh/config | grep -v '*' | cut -b 6- | fzf --query "$LBUFFER")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}"
zle accept-line
fi
zle reset-prompt
}
zle -N ssh-fzf
bindkey '^\' ssh-fzf
function history-fzf() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(history -n 1 | eval $tac | fzf --query "$LBUFFER")
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N history-fzf
bindkey '^r' history-fzf
export FZF_DEFAULT_COMMAND='rg --files'
less $(rg .|fzf --preview="cat {1}") #要修正
sudo apt install ripgrep
一般向けサイト
ITエンジニア向けサイト
英語サイト
Portfolio
Copyright (c) 2026 インフラエンジニアのPC環境 All Rights Reserved.