Skip to content

Instantly share code, notes, and snippets.

@theMackabu
Created August 31, 2024 23:33
Show Gist options
  • Save theMackabu/f7987562f7a92b58590c0937c3ba22d9 to your computer and use it in GitHub Desktop.
Save theMackabu/f7987562f7a92b58590c0937c3ba22d9 to your computer and use it in GitHub Desktop.
useful zsh commands/aliases
# get current git statistics
gitstats() {
git log --shortstat --author="$(git config user.name)" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, ratio }' -
}
# link homebrew items that aren't in path
function blink() {
local targetdir
targetdir=($(brew --cellar $1)/*/bin) || return
local linksdir=$(brew --repo)/bin
for ex in "$targetdir"/*(^/)
do
local exname=${ex##*/}
if builtin which "$exname" &>/dev/null
then
echo " $exname already available in the path - skipped"
else
ln -s "$ex" "$linksdir/" && echo "$exname linked from $linksdir"
fi
done
}
# get path
alias path='echo -e ${PATH//:/\\n}'
# youtube DL mp3
alias ytmp3="yt-dlp -f bestaudio --extract-audio --audio-format mp3 -o '%(title)s.%(ext)s'"
# youtube DL mp4
alias ytdl="yt-dlp -f best --format mp4 -o '%(title)s.%(ext)s'"
# arc browser without json override
alias arc="open -a Arc.app --args --disable-blink-features=PrettyPrintJSONDocument"
# youtube DL cover art
alias ytcov="ytmp3 --add-metadata --ppa \"ThumbnailsConvertor+ffmpeg_o:-c:v png -vf crop='ih'\" --embed-thumbnail --postprocessor-args \"-id3v2_version 3\" -o \"%(uploader)s/%(title)s.%(ext)s\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment