From 79cdc0f23ba3cbbf37e7bd83c874d20ce060bac5 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 21 Nov 2024 22:32:52 +0100 Subject: [PATCH] Add commands for fzfd (fzf for directories), cdf, cpf, mvf, rmf (all variants that use fzf, in the case of cp and mv that takes two paths, they accept an argument for the second path, or if left empty uses fzf for the first and second path) --- home/.zshrc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/home/.zshrc b/home/.zshrc index e22912a..1c8abb3 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -130,6 +130,7 @@ fi alias pilot="gh copilot" alias ps="gh copilot suggest" alias pe="gh copilot explain" +alias fzfd="fd --type d --hidden --follow --exclude .git | fzf" # Alias functions vif() { @@ -148,6 +149,42 @@ catc() { cat "$1" | wlc } +cdf() { + cd "$(fzfd)" +} + +cpf() { + if [ -z "$1" ]; then + cp "$(fzf)" "$(fzfd)" + else + cp "$(fzf)" "$1" + fi +} + +mvf() { + if [ -z "$1" ]; then + mv "$(fzf)" "$(fzfd)" + else + mv "$(fzf)" "$1" + fi +} + +rmf() { + if [ -z "$1" ]; then + mv "$(fzf)" "$(fzfd)" + else + mv "$(fzf)" "$1" + fi +} + +rmdf() { + if [ -z "$1" ]; then + mv "$(fzf)" "$(fzfd)" + else + mv "$(fzf)" "$1" + fi +} + # Check if tmux is already running or if the session is interactive if [[ -z "$TMUX" ]] && [[ $- == *i* ]]; then # Create a new tmux session, if one doesnt exist, give it the main name, never attach to a session