Add cdf alias

This commit is contained in:
Yan Lin 2025-08-23 12:09:00 +08:00
parent 989430492e
commit d1e8fe0a0a
2 changed files with 19 additions and 0 deletions

View file

@ -113,6 +113,19 @@ in
# Zoxide configuration - replace cd with z for smart directory jumping
eval "$(zoxide init zsh --cmd cd)"
# Function to cd to directory containing a file selected with fzf
function cdf() {
local file
file=$(fd "$@" ~ | fzf)
if [[ -n "$file" ]]; then
if [[ -d "$file" ]]; then
cd "$file"
else
cd "$(dirname "$file")"
fi
fi
}
'';
};