From 4488e05a868b68e1a8806df113add8aa3e726356 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 5 Oct 2023 19:40:05 +0200 Subject: [PATCH] refactor --- zsh/{vars.zsh => env.zsh} | 0 zsh/exa.zsh | 3 --- zsh/eza.zsh | 3 +++ zsh/ffmpeg.zsh | 2 ++ zsh/fn.zsh | 8 ++++++++ zsh/mac_files.zsh | 2 ++ zsh/media.zsh | 11 +++++++++++ zsh/mkcd.zsh | 1 + zsh/std.zsh | 7 +++++++ zsh/video_presets.zsh | 6 ------ zsh/web.zsh | 6 ++++++ zsh/youtube-dl.zsh | 26 +++++++++++++++++--------- 12 files changed, 57 insertions(+), 18 deletions(-) rename zsh/{vars.zsh => env.zsh} (100%) delete mode 100644 zsh/exa.zsh create mode 100644 zsh/eza.zsh create mode 100644 zsh/ffmpeg.zsh create mode 100644 zsh/fn.zsh create mode 100644 zsh/std.zsh delete mode 100644 zsh/video_presets.zsh create mode 100644 zsh/web.zsh diff --git a/zsh/vars.zsh b/zsh/env.zsh similarity index 100% rename from zsh/vars.zsh rename to zsh/env.zsh diff --git a/zsh/exa.zsh b/zsh/exa.zsh deleted file mode 100644 index 8143cc4..0000000 --- a/zsh/exa.zsh +++ /dev/null @@ -1,3 +0,0 @@ -alias ls="exa" -alias l="exa -l" -alias la="exa -la" diff --git a/zsh/eza.zsh b/zsh/eza.zsh new file mode 100644 index 0000000..1feeaad --- /dev/null +++ b/zsh/eza.zsh @@ -0,0 +1,3 @@ +alias ls="eza" +alias l="eza -l" +alias la="eza -la" diff --git a/zsh/ffmpeg.zsh b/zsh/ffmpeg.zsh new file mode 100644 index 0000000..5d0d912 --- /dev/null +++ b/zsh/ffmpeg.zsh @@ -0,0 +1,2 @@ +# print duration of video file +alias ffprobe_duration="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1" \ No newline at end of file diff --git a/zsh/fn.zsh b/zsh/fn.zsh new file mode 100644 index 0000000..c6ae8f4 --- /dev/null +++ b/zsh/fn.zsh @@ -0,0 +1,8 @@ +# rename +# rename files with replace pattern +function rename() { + rnr -f --no-dump "$1" "$2" ./* +} + +alias cat="bat -p" +alias gfold="gfold -d classic" \ No newline at end of file diff --git a/zsh/mac_files.zsh b/zsh/mac_files.zsh index 5dcd9de..1c0c730 100644 --- a/zsh/mac_files.zsh +++ b/zsh/mac_files.zsh @@ -1,8 +1,10 @@ +# find mac files function find_mac_files() { find . -name '.DS_Store'; find . -name '._*'; } +# delete mac files function clean_mac_files() { find . -name '.DS_Store' -type f -delete; find . -name '._*' -type f -delete diff --git a/zsh/media.zsh b/zsh/media.zsh index b610c3d..2c637ed 100644 --- a/zsh/media.zsh +++ b/zsh/media.zsh @@ -1,7 +1,18 @@ +# convert +# convert all files with old_ext to new_ext using ffmpeg function convert() { for i in *.$1; do ffmpeg -i "$i" "${i%.*}.$2"; done } +# remux all mkvs in current dir to mp4 function mkvToMp4() { for i in *.mkv; do ffmpeg -i "$i" -map 0 -c copy "${i%.*}.mp4"; done } + +# gif2avif +# convert gif to avif image +function gif2avif() { + ffmpeg -i "$1" -pix_fmt yuv444p10 -strict -1 "${1%.*}.y4m"; + avifenc "${1%.*}.y4m" "${1%.*}.avif"; + rm -v "${1%.*}.y4m"; +} \ No newline at end of file diff --git a/zsh/mkcd.zsh b/zsh/mkcd.zsh index 57ac072..ab17477 100644 --- a/zsh/mkcd.zsh +++ b/zsh/mkcd.zsh @@ -1,3 +1,4 @@ +# create directory and move into it function mkcd() { mkdir $1 && cd $1 } diff --git a/zsh/std.zsh b/zsh/std.zsh new file mode 100644 index 0000000..e1fb9e5 --- /dev/null +++ b/zsh/std.zsh @@ -0,0 +1,7 @@ +# usage: skip N +# skip n elements from input +function skip() { + local n=$1 + shift + tail -n +"$((n+1))" "$@" +} \ No newline at end of file diff --git a/zsh/video_presets.zsh b/zsh/video_presets.zsh deleted file mode 100644 index ad9ac69..0000000 --- a/zsh/video_presets.zsh +++ /dev/null @@ -1,6 +0,0 @@ -function mkVideoProj() { - mkdir $1 && cd $1; - mkdir -p Media; - mkdir -p Renders; - mkdir -p Thumbnails; -} diff --git a/zsh/web.zsh b/zsh/web.zsh new file mode 100644 index 0000000..dbbf7e0 --- /dev/null +++ b/zsh/web.zsh @@ -0,0 +1,6 @@ + +# webhook_post +# send curl post request +function webhook_post() { + curl -X POST "$1" +} \ No newline at end of file diff --git a/zsh/youtube-dl.zsh b/zsh/youtube-dl.zsh index b1dc84b..e753e77 100644 --- a/zsh/youtube-dl.zsh +++ b/zsh/youtube-dl.zsh @@ -1,10 +1,18 @@ -alias downloadVid="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1080]+bestaudio\" --write-thumbnail" -alias downloadVid1440="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=1440]+bestaudio\" --write-thumbnail" -alias downloadVid4K="yt-dlp --downloader aria2c -o \"%(title)s.%(ext)s\" -f \"bestvideo[height<=2160]+bestaudio\" --write-thumbnail" -alias downloadAudio="yt-dlp --downloader aria2c -o \"%(playlist_index)s %(title)s.%(ext)s\" -x" -alias downloadMusic="yt-dlp --downloader aria2c -x --add-metadata -o \"%(playlist_title)s/%(playlist_index)s %(title)s.%(ext)s\"" -alias dlBeat="yt-dlp --downloader aria2c --no-playlist --audio-format m4a -x" -alias downloadYT="yt-dlp --downloader aria2c --write-thumbnail -o \"%(title)s.%(ext)s\" --embed-thumbnail --embed-chapters --embed-info-json --convert-thumbnails jpg" +USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" + +alias yt-dlp="yt-dlp \ +--downloader aria2c \ +--cookies-from-browser brave \ +--user-agent \"$USER_AGENT\"" + +alias downloadAudio="yt-dlp -o \"%(playlist_index)s %(title)s.%(ext)s\" -x" +alias downloadMusic="yt-dlp -x --add-metadata -o \"%(playlist_title)s/%(playlist_index)s %(title)s.%(ext)s\"" +alias dlBeat="yt-dlp --no-playlist --audio-format m4a -x" +alias downloadYT="yt-dlp --write-thumbnail \ +-o \"%(title)s.%(ext)s\" --embed-thumbnail \ +--embed-chapters --embed-info-json \ +--convert-thumbnails jpg" + function downloadList() { - cat $1 |xargs -I _ yt-dlp --downloader aria2c _ -} + cat $1 |xargs -I _ yt-dlp --downloader aria2c _ +} \ No newline at end of file