Skip to content

Instantly share code, notes, and snippets.

View thingsiplay's full-sized avatar

Tuncay thingsiplay

View GitHub Profile
@thingsiplay
thingsiplay / lpl2vars
Created November 25, 2026 20:33
RetroArch Playlist Reader - Proof of concept
#!/usr/bin/env bash
# Proof of concept to read all keys and values from a RetroArch playlist
# file in JSON format into dedicated variables for instant access. It still
# requires the typical formatting of the playlist and cannot handle arbitrary
# JSON files. But for our use case this should be enough.
default_file="${HOME}/.config/retroarch/playlists/builtin/content_history.lpl"
if [[ "${#}" -eq 0 ]]; then
file="${default_file}"
@thingsiplay
thingsiplay / randomretroarch
Created November 23, 2026 22:40
Random RetroArch
#!/usr/bin/env bash
# Random RetroArch
# Play a random game from a RetroArch playlist.
#
# Requires `jq` and off course `retroarch`.
#
# Examples:
#
# randomretroarch
@thingsiplay
thingsiplay / gitlog
Created November 5, 2026 13:11
Git log commands
#!/usr/bin/env bash
# List Git log messages by tag or commit range. Defaults to HEAD.
# gitlog [from] [to]
#
# from and to can be a tag or commit id:
# gitlog v1.22.2
# gitlog 281b532
# gitlog 281b532 b0353a6
@thingsiplay
thingsiplay / diffuse.sh
Last active March 16, 2026 18:13
Diffuse - Compare 2 Text Content
#!/usr/bin/env bash
title="Diff - Compare 2 Texts"
output_size="720x720"
file1="$(mktemp)"
file2="$(mktemp)"
file3="$(mktemp)"
kdialog --title "${title} (input)" --textinputbox "Input Text 1" >> "${file1}"
@thingsiplay
thingsiplay / count-roms.sh
Last active March 7, 2026 22:37
Count ROMs
#!/usr/bin/env bash
# Count ROMs
# Simple script to list ROM files by stripping parts of filename starting with
# one of the following characters '_', '(' or '['. Then count remaining
# duplicates and list them with a counter for each name. This is intended to
# count my Romhacks played on emulators, but may work well for any collection.
#
# First argument can be a directory. Defaults to current directory. Files are
# NOT searched recursively.
@thingsiplay
thingsiplay / flatpak-list-json
Created December 30, 2025 01:42
Flatpak list output as JSON format
#!/usr/bin/env bash
# Flatpak list output as JSON format
# Examples with jq:
# flatpak-list-json | jq -r '.[].name'
# flatpak-list-json | jq -r '.[0:2].[].application'
# flatpak-list-json | jq '.[0:2]'
# flatpak-list-json | jq '.[] | select(.description | contains("video"))'
@thingsiplay
thingsiplay / treegrep()
Created October 1, 2025 03:53
Grep output with tree format (Bash function)
# Bash function
#
# usage: treegrep GREPOPTIONS "pattern"
treegrep() {
# grep:
# --recursive like --directories=recurse
# --files-with-match print only names of FILEs with selected lines
# tree:
# --fromfile Reads paths from files (.=stdin)
# -F Appends '/', '=', '*', '@', '|' or '>' as per ls -F.
@thingsiplay
thingsiplay / thing.py
Last active June 22, 2025 23:17
Python Tutorial: argparse advanced-help with additional options
#!/usr/bin/env python3
import sys
import argparse
long_help = False
for arg in sys.argv:
if arg == "--":
break
if arg == "--long-help":
@thingsiplay
thingsiplay / history-print-paths.sh
Last active June 15, 2025 21:35
List all existing program paths from your Bash's history.
#!/usr/bin/env bash
# 1. history and $HISTFILE do not work in scripts. Therefore a direct path to
# the file is needed.
# 2. awk gets the first part of the command line, resulting in the command name.
# 3. List of command names is then sorted and duplicate entries are removed.
# 4. type -P will expand command names to paths, similar to which. But it will
# also expand aliases and remove functions from the list.
# 5. Final output is then sorted again.
#!/usr/bin/env bash
local="${HOME}/.config/retroarch"
repo='https://github.com/libretro/docs'
open='okular'
cd -- "${local}" || exit
if [[ "${1}" == '' ]]; then
mode="$(printf 'open\nupdate' | fzf)"