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)
This commit is contained in:
Martin Larsson 2024-11-21 22:32:52 +01:00
parent f2c43242f5
commit 79cdc0f23b

View file

@ -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