nixos/nate-work/dotfiles/zsh_functions

24 lines
682 B
Plaintext
Raw Normal View History

2024-12-17 14:40:05 -07:00
yt-audio() {
nix-shell -p yt-dlp --run "yt-dlp -x $1 --audio-format mp3"
}
docker_mysql() {
if [ -z "$1" ]; then
echo "Usage: docker_mysql <mysql_container_name>"
return 1
fi
docker exec -it "$1" mysql -u root -ppassword
}
# Tab-completion for docker_mysql function
_complete_docker_mysql() {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W "$(docker ps --format '{{.Names}}' | grep mysql)" -- $cur))
}
# Register the completion for the docker_mysql function
complete -F _complete_docker_mysql docker_mysql
# Git restore file, like git restore but works for staged changes as well
gres() {
git restore --source=HEAD --staged --worktree -- "$1"
}