Skip to content

Instantly share code, notes, and snippets.

@AgustinParmisano
Last active November 16, 2025 09:03
Show Gist options
  • Select an option

  • Save AgustinParmisano/6d43b424db7720ff4a91d787685bd2e5 to your computer and use it in GitHub Desktop.

Select an option

Save AgustinParmisano/6d43b424db7720ff4a91d787685bd2e5 to your computer and use it in GitHub Desktop.
fast file-dir search .zshrc config
# Add wisely, as too many plugins slow down shell startup.
# history and fzf plugins allows ctrl+r fzf like command search
plugins=(git history fzf)
alias cdf='cd "$(dirname "$(fd -a -t f . ~ --hidden --exclude .git 2>/dev/null | fzf --preview="bat --style=full --color=always {}" --preview-window=right)")"'
# Define la función para buscar y navegar (cd function with fzf)
function cdf_widget {
# Ejecuta fzf y fd con bat para la vista previa.
# Usamos -a para rutas absolutas y 2>/dev/null para ignorar errores de permisos
local selected_file
selected_file=$(fd -a -t f . ~ --hidden --exclude .git 2>/dev/null | fzf --preview="bat --style=full --color=always {}" --preview-window=right)
# Si se selecciona un archivo, cambiamos al directorio padre
if [[ -n "$selected_file" ]]; then
local parent_dir
parent_dir=$(dirname "$selected_file")
cd "$parent_dir"
fi
# Resetea la línea de comandos de Zsh
zle reset-prompt
}
# Carga la función como un widget de Zsh
# zle -N cdf_widget
# Asigna la combinación de teclas Ctrl+F (ó ^F) al widget
# bindkey '^F' cdf_widget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment