Skip to content

Instantly share code, notes, and snippets.

@eggplants
eggplants / ghcr.sh
Last active April 12, 2024 12:14
How to get information from ghcr Docker Registry HTTP API V2 with curl
#!/usr/bin/env bash
# ref: https://github.community/t/how-to-check-if-a-container-image-exists-on-ghcr/154836/3
# public image's {USER}/{IMAGE}
USER_IMAGE=eggplants/asciiquarium-docker
# get token ('{"token":"***"}' -> '***')
TOKEN="$(
curl "https://ghcr.io/token?scope=repository:${USER_IMAGE}:pull" |
awk -F'"' '$0=$4'
@JPvRiel
JPvRiel / bash_replace_newlines_string_substitution.md
Last active June 15, 2023 00:24
Replacing newlines with commas (or other text) using pure bash string substitution (not awk).

In this example

  • Multiline input can be caputured by spreading openening and closing quote accross lines
  • Newlines can be replaced using built-in bash text substitution
  • The main trick is knowing that $'\n' is the way to specify the newling within the subsitution
  • Note, echo output of a var without quotation replaces newlines with spaces
$ t='1
> 2

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: