guide:

Things I Keep Having to Google

Posted on 2023-01-12

This isn't really a guide to anything in particular, I just wanted an easily accessible reference for all the things I'm sick of wading through google results for, or otherwise seem to need help remembering. I've put it here in case someone else might find this helpful. I'll likely be adding to this as I find myself repeatedly googling things.

Binding things to just the Super key in KDE

  1. Bind it to some other keyboard shortcut using KDE's typical GUI methods. Any shortcut will do.
  2. Find the entry for it in ~/.config/khotkeysrc. There should be a line that looks like: Uuid={77575b17-36d6-4b4e-b01f-2f1156e38583}. Copy everything inside the curly braces, including the braces themselves.
  3. Run the following commands:
$ kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.kglobalaccel,/component/khotkeys,org.kde.kglobalaccel.Component,invokeShortcut,<YOUR UUID HERE>"
$ qdbus org.kde.KWin /KWin reconfigure

Linux command line/Bash stuff

pipeline

command | command2uses the output of one command as the input to the next
command > filesaves the output of a command to a file
command < fileuses a file as the input to a command
command < fileA > fileBwill therefore run command with the contents of fileA as the input, and save the output to fileB
command <<< "string or $variable"will use the string or variable as the input to a command, the same as  < file

variables

variable=valueassigns a variable
$variablereferences it
$(command)lets you treat the output of a command like a variable reference
$((number+variable))does the same thing for integer math expressions.
$(( $(command) ))
$(( variable ))
This can also just convert strings into integers.
"te$(command)xt"
"as$((math))df"
Both can be inserted into strings.
"some $variable text"
"more${variable}text"
Both of these are valid ways to insert a variable into a string.

grep

-vInverts it, so matches are excluded
-E "/regex/"Lets you use regex

cut

-d 'string'Determines the delimiter string, the default is the TAB character
-f nSpecifies a field to output, delimited by -d
sed 's/  */ /g' | cut -d ' 'Piping your thing through this helps with parsing a lot of Linux commands that output tabular data

sed

sed "s/regex/replacement/flags"The basic sed replacement command, checks a line of input against the provided regular expression regex and replaces matches with replacement.
sed "s/a/b/;s/c/d/"Multiple sed commands can be strung together in one, like so.
sed "s/a/b/g"The g flag makes sed replace all occurences of the pattern, not just the first
sed "s/a/b/<number>"Insert any number to tell sed to replace only that occurence. Counts from 1. Theoretically, s/a/b/ is the same as s/a/b/1.
sed "s/a/b/i"GNU extension - Match case-insensitively.
sed "s/^a/b/"Require that a match be at the beginning of the line.
sed "s/a$/b/"Require that a match be at the end of the line.
sed "s/^a$/b/"Require that a match be both at the beginning and the end - in other words, require that a match be the entire line.

find

findLists every file and directory in the current working directory
find /dirDoes the same for the directory you specify
find -name "foo"Only lists things with a matching name. * can be used as a wildcard.
find -exec command {} \;Runs command on everything found by find. {} is replaced by the output.

misc

xrandr --output <display name> --brightness <brightness>Janky software-side display brightness setting with xrandr
wget "https://example.com/file.zip" -O temp.zip; unzip temp.zip; rm temp.zipBash one-liner to unzip a file from the internet to the current directory
yt-dlp -x --audio-format flac --audio-quality 0 -P ~/Music/Library/ -o "%(uploader)s - %(title)s.%(ext)s"My standard yt-dlp command for ripping music from Youtube and Soundcloud. I have an alias for this so I don't have to write it out every time.
alias myalias="command go here"Set an alias in bash. Put this in your .bashrc or similar to make it permanent.

Webdev stuff

Tables

PHP

Song Lyrics

I don't actually have a solution for this one, I just wish there was a resource for looking up the lyrics to songs and looking up songs by their lyrics that wasn't an SEO leech site.

Comments