Just some stuff about me.
C-x C-e — edit command in $EDITOR (vim for me)C-a — go to start of commandC-e — go to end of commandAlt-f — go forward by wordAlt-b — go backward by wordpushd $dir — push cwd to stack, cd to dirpopd — pop the directory from the stack and cd to itdirs — list directory stackexec builtinusage:
exec vim replaces the shell with vim, when you close vim you quit the terminal.examples:
exec 1> >(lolcat >&2) # make shell redirect stdout to process lolcat,
# which redirects to stderr
exec 3< input.txt # create a new file descriptor, reading from input.txt
read LINE <&3 # read from the file descriptor into LINE
exec 3<&- # close the file descriptor
exec 4> output.log # create a new file descriptor for writing to output.log
echo “foo” >&4 # write “foo” to file descriptor 4 (output.log)
exec 4>&- # close the file descriptor
echo “foo bar” > file # write “foo bar” to file
exec 5<>file # open file for rw on file descriptor 5
read -n 3 var <&5 # read 3 characters from file descriptor 5 into var
echo "Hello" >&5 # write "Hello" into the file
exec 5>&- # close the file for writing
exec 5<&- # close the file for reading
set -o vi — vim keybindings for shellset -o emacs — emacs keybindings for shellset -e — exit script on errorset -x — print code as it executes${var##*/} — remove longest string of anything followed by / from var${var#*/} — same but shortest${var%%*/} — same as above but from end!! — previous command!$ — last argument of previous command!^ — first argument of previous command!* — all arguments of previous command!:a-b — arguments number a to b of previous command!$:h — only the head of the previous argument (e.g. “^x^y^ — replace x by y in previous command&> file — redirect all output to a file(1)>&2 — redirect stdout to stderr, the 1 is implicit2>&1 — redirect stderr to stdout>file — redirect stdout to file, overwriting>>file — redirect stdout to file, appending<(command) — pass output of command as stdin>(command) — redirect stdout to command<<< — here string, pass string from stdin as input<<EOF ... EOF - here document, pass multiline string as inputorder matters, creating a new redirection essentially duplicates the file descriptor (e.g. “command > file 2>&1” != “command 2>&1 > file“
ffmpeg -i in.mkv -f srt -i in.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv - add subtitles to videofor f in ./*.ext; do echo "file '$f'" >> list.txt; done; ffmpeg -f concat -safe 0 -i list.txt -c copy output.ext - concatenate videosffmpeg -i in.vtt out.srt - convert vtt subtitles to srtbc <<< "obase=2; ibase=16; F" - convert hex to binary (when you set ibase, everything has to be in that base. so if you wanted to reset output to decimal, you’d have to set obase=A).