# DevOps life
abbr ap ansible-playbook
abbr ad ansible-doc
abbr h helm
abbr k kubectl
abbr kx kubectx
abbr kn kubens
abbr p pulumi

# remap
alias cp 'cp -vir'
alias mv 'mv -vi'
alias rm 'rm -vr'
alias mkdir 'mkdir -vp'
alias cargo 'cargo auditable'

# neovim
abbr v nvim
abbr vv 'fzf --prompt "Edit files: " --preview "{{ xdg_dir.bin_home }}/preview.sh {} 2>/dev/null" --bind "enter:become(nvim {+})"'

# emacs
abbr e 'emacs -nw'
abbr em 'emacsclient -c -a "emacs"'

# rsync
abbr rsyncdir 'rsync -avP --delete-after'

# yt-dlp
abbr yoump3 'yt-dlp --extract-audio --audio-format mp3 --embed-thumbnail --audio-quality 0'
abbr youflac 'yt-dlp --extract-audio --audio-format flac --audio-quality 0'
abbr youlist 'yt-dlp --yes-playlist'

# Lazy cd-ing
function __multicd; echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../); end
abbr dotdot --regex '^\.\.+$' --function __multicd

# !! (previous command)
function __last_history_item; echo $history[1]; end
abbr '!!' --position anywhere --function __last_history_item

# Other nice things
function dir_prune
  if test -d "$argv[1]"
    printf "==> Prune directory \033[1;33m$argv[1]\033[0m\n"
    for dir in (fd --full-path "$argv[1]" --type empty --type directory)
      echo "+ $dir"
      rmdir -p --ignore-fail-on-non-empty "$dir"
    end
  else
    printf "\033[1;31m$argv[1]\033[0m is not a directory\n"
    return 1
  end
end
