Last active 1741877163

These are my number one bash scripts. I can't live without them.

.bash_aliases Raw
1alias install_no="sudo pacman -Sy"
2alias install_ya="yay -S --noconfirm"
3alias backupvps="rsync -avhzr --delete --progress --rsh='ssh -p22' user@ip:/ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/swapfile","/boot/*"} /to/dir/"
4
5
6# Compress a video with CUDA acceleration (GPU from NVIDIA is required)
7function reducevideo {
8 ffmpeg -hwaccel cuda -i "$1" -c:v libx265 -vtag hvc1 -c:a copy "$2"
9}
10
11alias reducevideo="reducevideo"
12
13
14# Download videos from YouTube in full HD. Creates an JSON file with all the information about the video, includes the chapters, and more.
15function ytdl {
16 yt-dlp \
17 --check-formats \
18 --progress \
19 --ignore-errors \
20 --format "bv*[height<1080][ext=mp4]+ba" \
21 --merge-output mkv \
22 --write-info-json \
23 --write-annotations \
24 --write-thumbnail \
25 --convert-thumbnails jpg \
26 --add-metadata \
27 --convert-thumbnail jpg \
28 --embed-thumbnail \
29 --embed-chapters \
30 --embed-info-json \
31 --restrict-filenames \
32 --concurrent-fragments 3 \
33 --sponsorblock-mark all,-preview,-filler,-interaction \
34 -o "/to/dir/%(channel)s/%(upload_date>%Y-%m-%d)s - %(title)s.%(ext)s" "$1"
35
36 notify-send "Video file saved."
37}
38
39alias ytdl="ytdl"
40
41
42# Download a video from YouTube and convert it to a MP3 file. Embed the cover to the file.
43function ytdla {
44 yt-dlp \
45 --check-formats \
46 --progress \
47 --ignore-errors \
48 --write-info-json \
49 --no-call-home \
50 --add-metadata \
51 --audio-format "mp3" \
52 --extract-audio \
53 --format bestaudio/best \
54 --embed-thumbnail \
55 --restrict-filenames \
56 --concurrent-fragments 3 \
57 -o "/to/dir/%(uploader)s/%(upload_date>%Y-%m-%d)s - %(title)s (%(id)s).%(ext)s" "$1"
58
59 notify-send "Audio filed saved."
60}
61
62alias ytdla="ytdla"
63
64
65# Compress an image by reducing size and quality and remove all metadata. Inspired from Telegram.
66function reduceimage {
67 convert -resize 2000x2000 -quality 70 "$1".jpg "$1"-r.webp
68 exiftool -overwrite_original -all= "$1"-r.webp
69}
70
71alias reduceimage="reduceimage"