Skip to content

Instantly share code, notes, and snippets.

@AgustinParmisano
Last active December 6, 2025 14:04
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 "$(fdfind -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=$(fdfind -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
# Buscar y ejecutar bash en
docker-exec() {
local container_id
container_id=$(docker ps --format "table {{.Names}}\t{{.ID}}" | \
fzf --header-lines=1 --height 40% --layout=reverse | \
awk '{print $2}')
if [ -n "$container_id" ]; then
# Esto escribe el comando en la terminal para que lo edites o ejecutes
print -z "docker exec -it $container_id /bin/bash"
fi
}
alias de='docker-exec'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment