Skip to content

Instantly share code, notes, and snippets.

View jobwat's full-sized avatar

Jo Boiteau jobwat

  • Servian
  • Sydney
View GitHub Profile
@jobwat
jobwat / ssh-encrypt.sh
Created January 5, 2022 23:18
encrypt text with ssh key pair
## encrypt text with SSH key
# Notes:
# It's not as straightforward as someone would think!
# Need to convert the keys to an openssl known format (PEM) first.
# Also, SSH keys aren't meant to encrypt content larger than 200bytes
# Sources:
# https://superuser.com/questions/576506/how-to-use-ssh-rsa-public-key-to-encrypt-a-text
# https://serverfault.com/questions/706336/how-to-get-a-pem-file-from-ssh-key-pair
# https://superuser.com/questions/1679344/for-valid-pem-i-get-unable-to-load-private-key-by-openssh
@jobwat
jobwat / oneliner
Created February 14, 2024 00:06
list the remote branches with last commit authored by yourself
git branch -r | cut -d '/' -f 2- | grep -v '\->' | sort -u | while read branch; do [[ "$(git --no-pager log -n 1 --format='%ae' "origin/$branch" 2>/dev/null)" == "$(git config user.email)" ]] && echo $branch; done
@jobwat
jobwat / .gitconfig
Created June 5, 2024 06:41
git alias to update current repository password in osxkeychain
# ...
[alias]
# ...
echo-remote-proto-and-host = "!f(){ REMOTE=origin; git remote -v | grep $REMOTE | head -n1 | sed -E \"s/^$REMOTE\\t+([a-z]+):\\/\\/([^\\/]+).*/protocol=\\1\\nhost=\\2/\";};f"
clear-credentials = "!f(){ git echo-remote-proto-and-host | git credential-osxkeychain erase ;};f"
get-credentials = "!f(){ git echo-remote-proto-and-host | git credential-osxkeychain get ;};f"
update-password = "!f(){ (git echo-remote-proto-and-host; git get-credentials) | sed \"s/password=.*/password=$1/\" | git credential-osxkeychain store ;};f"
# Usage:
#. Copy your new password in clipboard