Skip to content

Instantly share code, notes, and snippets.

View AdamGagorik's full-sized avatar

Adam Gagorik AdamGagorik

View GitHub Profile
@AdamGagorik
AdamGagorik / cb
Created October 22, 2025 17:23
osc52 based clipboard script
#!/usr/bin/env bash
# cb — clipboard copy / paste using ONLY OSC 52 escape sequences
# Works in any terminal that supports OSC 52 (iTerm2, kitty,
# wezterm, recent xterm, etc.). No tmux handling, no xclip,
# no pbcopy.
set -euo pipefail
TIMEOUT=2 # seconds to wait for terminal’s reply when pasting
###############################################################################
@AdamGagorik
AdamGagorik / backup
Created October 22, 2025 14:02
Rsync wrapper with fzf
#!/usr/bin/env bash
set -euo pipefail
EXCLUDE_PATTERNS=()
SEARCH_ROOT="${SEARCH_ROOT:-$HOME}"
SEARCH_DEPTH="${SEARCH_DEPTH:-3}"
NO_PROMPT="${NO_PROMPT:-false}"
SRC_PATH=""
DST_PATH=""
@AdamGagorik
AdamGagorik / count
Created October 10, 2025 16:19
Count files
#!/usr/bin/env bash
set -euo pipefail
show_usage() {
echo "Usage: $0 [--max-depth N] <ext> <ext> ..."
}
# parse options
opts=$(getopt -o h --long help,max-depth: -- "$@")
if [ $? != 0 ]; then
@AdamGagorik
AdamGagorik / mount.sh
Created October 3, 2025 16:43
Mount a remote directory locally temporarily for editing in local IDE
#!/usr/bin/env bash
set -euo pipefail
SOURCE="$(dirname "${BASH_SOURCE[0]}")"
declare -a R_PATHS=(
"$1:$2"
)
declare -a L_PATHS=(
@AdamGagorik
AdamGagorik / remove_fast.sh
Created October 1, 2025 18:31
Rsync based directory removal
#!/usr/bin/env bash
set -e
if [ -z "${1}" ]; then
echo "Usage: $(basename "${0}") <path>"
exit 1
fi
TO_REMOVE=$(realpath "${1}")
@AdamGagorik
AdamGagorik / sync_helper.sh
Created October 1, 2025 17:41
Rsync + fd + fzf
#!/usr/bin/env bash
set -euo pipefail
EXCLUDE_PATTERNS=()
SEARCH_ROOT="/"
NO_PROMPT=false
SRC_PATH=""
DST_PATH=""
usage() {
@AdamGagorik
AdamGagorik / mdclip
Last active January 2, 2025 20:58
Convert clipboard contents from markdown to html
#!/usr/bin/env python3
"""
Convert the contents of the clipboard from markdown to html that can be pasted into editors expecting rich text.
# Read input from clipboard (default)
➜ echo "**TEST**" | cb
➜ mdclip
# Read input from command line
@AdamGagorik
AdamGagorik / harpoon
Last active July 20, 2024 22:05
A script to memorize common directories
#!/usr/bin/env python3
"""
Memorize key directories and cd to them.
examples:
cd $(harpoon)
cd $(harpoon key)
harpoon add <key> <path>
harpoon register <shell>
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CACHE_FILE="${SCRIPT_DIR}/latest-clion-version.txt"
CACHE_TTL=$((60 * 60 * 24 * 7))
if [[ "$#" -gt 0 ]]; then
if [[ "$1" = "-f" ]] || [[ "$1" = "--force" ]]; then
FORCE=1
else
# change the prefix from 'C-b' to 'C-a'
# (remap capslock to CTRL for easy access)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# set default shell
set-option -g default-shell /usr/bin/zsh
# start with window 1 (instead of 0)