We all know this. We need to do a specific task and with the help of the internet we find a specific tool alongside command line parameters to do the job right from the shell.
What is a good way of collecting/documenting these snippets on your own for future reference and use? Just a text file in the home folder?
I do mine in Obsidian, I just have a folder for ‘computer notes’ and whenever I figure out a new thing I drop it in there.
Some stuff I use often I set up as an alias too. So for example I have
alias yt='yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4"'
for my most commonly used yt-dlp settings, so now I can just doyt [URL of video]
to quickly download something from YouTube. Oralias rs="sudo rsync --ignore-existing -rav"
for my rsync settings for a specific backup folder I copy a lot.In my obsidian i use the daily note feature heavily and if i come across a useful snippet or info i will add a tag and content like below. I found tagging to be helpful because i do not have to spend effort up front putting the file in the “right” folder. I have cleaned some of these up by removing them from my daily notes and into dedicated notes, but only after i have collected quite a few for a specific language or tech and there is a need for me to put more structure around the information.
#codesnippet/<language or tech stack> Write a description to help me remember what this is for
<insert code here>
I prefer my
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --concurrent-fragments 12 --throttled-rate 100K -o "%(uploader)s/%(playlist_title|)s/%(playlist_index&{} - |)s%(title)s.%(ext)s"
Since it saves it based on the channel and if is a playlist, it makes a folder based in that
-
Not sure if
--concurrent-fragments 12 --throttled-rate 100K
does actually something.I’m interested in the rsync part for backups, do you have a good guide or video for that? Thanks
I don’t really have a guide or anything for it to hand, but essentially what that alias is doing is:
rsync
= running rsync--ignore-existing
= as you might have guessed, this tells rsync not to copy a file if it already exists at the destination.-rav
= additional arguments. r = recursive, IE also copy subfolders. a = archive mode, preserves things like symlinks etc. and v = verbose, just tells you extra info about what’s going on.So with that alias, I can just type
rs [target folder] [destination folder]
and it’ll copy it across exactly as it is, ignore anything that’s already there and tell me precisely what it’s doing.