Skip to content

Instantly share code, notes, and snippets.

View trustin's full-sized avatar
🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂

Trustin Lee trustin

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂
View GitHub Profile
@trustin
trustin / setup-docker.sh
Created January 10, 2024 11:37
How to install Docker on macOS without using Docker Desktop
#!/usr/bin/env bash
set -Eeuo pipefail
# Install Docker CLI and Docker Compose, etc.
brew install docker docker-compose docker-credential-helper
# Configure Docker CLI.
mkdir -p "$HOME/.docker/cli-plugins"
ln -sfn '/opt/homebrew/opt/docker-compose/bin/docker-compose' "$HOME/.docker/cli-plugins/docker-compose"
echo '{
@trustin
trustin / remove-mkv-tracks.sh
Created August 5, 2023 03:44
Remove the tracks that match certain criteria from MKV files (using jq)
#!/usr/bin/env bash
set -Eeuo pipefail
if [[ $# -lt 2 ]]; then
echo "Usage: $(basename "$0") <preset or jq condition> <files or directories...>"
echo 'Presets: subrip_only, anime'
exit 1
fi
JQ_COND="$1"
#!/usr/bin/env bash
set -Eeuo pipefail
echo_and_run() {
echo "> $*"
"$@"
}
setup_sudo() {
# Ask for the administrator password upfront
@trustin
trustin / sjk.sh
Created March 7, 2022 07:10
SJK (Swiss Java Knife) launcher script
#!/usr/bin/env bash
set -Eeuo pipefail
if [[ -z "${JAVA_HOME:-}" ]]; then
JAVA='java'
else
JAVA="$JAVA_HOME/bin/java"
fi
SJK_VERSION='0.20'
SJK_PATH="$HOME/.local/opt/sjk/sjk-plus-$SJK_VERSION.jar"
@trustin
trustin / karabiner.json
Created September 10, 2021 02:45
Trustin's Karabiner-Elements settings
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@trustin
trustin / logid.cfg
Last active November 22, 2023 08:36
logiops settings for Logitech MX Anywhere 3 and 2 (/etc/logid.cfg)
// /etc/logid.cfg
devices: ({
name: "MX Anywhere 3";
hiresscroll: {
hires: true;
invert: false;
target: true;
up: {
mode: "Axis";
@trustin
trustin / ffmpeg-1080p.sh
Last active July 5, 2021 07:25
ffmpeg-1080p.sh: Scales down and transcodes a video file into HEVC with ffmpeg + CUDA
#!/bin/bash -e
if [[ $# -gt 1 ]]; then
while [[ $# -gt 0 ]]; do
"$0" "$1"
shift
done
exit 0
fi
@trustin
trustin / git-trigger-build.sh
Last active January 22, 2024 05:14
git-trigger-build: Triggers a CI build by pushing an empty commit
#!/bin/bash -e
# Stash the staged files if any.
NEEDS_UNSTASH=0
if ! git diff --staged --exit-code >/dev/null; then
echo -ne '\033[1;32m'
echo -n 'Stashing the staged files'
echo -e '\033[0m'
git stash
NEEDS_UNSTASH=1
@trustin
trustin / bash_prompt.sh
Last active July 27, 2018 09:40
Trustin's Bash prompt
#!/bin/bash
# Git-aware bash command prompt
#
# Put this script at $HOME/.bash_prompt and add the following to your .bashrc:
#
# if [[ -f "$HOME/.bash_prompt" ]]; then
# if [[ -z "$PROMPT_COMMAND" ]]; then
# PROMPT_COMMAND="$HOME/.bash_prompt"
# else
# PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} $HOME/.bash_prompt"
#!/bin/bash -e
HEAD_COMMIT_ID=$(git rev-parse HEAD)
if [[ -n "$HEAD_COMMIT_ID" ]]; then
git commit --amend --reuse-message="$HEAD_COMMIT_ID"
git push --force
fi