Skip to content

Instantly share code, notes, and snippets.

@uncenter
Last active April 9, 2024 14:08
Show Gist options
  • Save uncenter/0580584e5238fb0306a4b7f53aa9f508 to your computer and use it in GitHub Desktop.
Save uncenter/0580584e5238fb0306a4b7f53aa9f508 to your computer and use it in GitHub Desktop.
Take screenshots of files with specified extensions with https://github.com/Aloxaf/silicon.
#!/usr/bin/env bash
# You can run the following command to execute this script:
# curl https://gist.githubusercontent.com/uncenter/0580584e5238fb0306a4b7f53aa9f508/raw/01a0b3b07cfdcc11931590d4652d24089f656f2f/siliconify.sh | sh
# Requires https://github.com/charmbracelet/gum, https://github.com/Aloxaf/silicon, and https://github.com/sharkdp/fd to be installed locally.
extensions=$(fd -tf | awk -F. '!a[$NF]++{print $NF}')
files=()
for ext in $(gum choose --no-limit ${extensions[@]}); do
files+=($(fd -e $ext))
done
selected=$(gum choose --no-limit "${files[@]}")
for file in $selected; do
silicon "$file" --output "$(echo $file | sed 's/\//-/g').png" --window-title "$file" --pad-horiz 0 --pad-vert 0 --background '#fff0'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment