From d0c754055ddfcc56feae567b16b9044baada1386 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 26 Jun 2021 20:04:40 +0200 Subject: Add e, ge, decrypt, encrypt, and encrypt-nosign MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- emacs/Makefile | 4 ++++ git/Makefile | 4 ++++ git/ge | 8 ++++++++ gnupg/Makefile | 8 ++++++++ gnupg/decrypt | 13 +++++++++++++ gnupg/encrypt | 10 ++++++++++ gnupg/encrypt-nosign | 10 ++++++++++ 7 files changed, 57 insertions(+) create mode 100755 git/ge create mode 100755 gnupg/decrypt create mode 100755 gnupg/encrypt create mode 100755 gnupg/encrypt-nosign diff --git a/emacs/Makefile b/emacs/Makefile index c22b5f4..c7f8527 100644 --- a/emacs/Makefile +++ b/emacs/Makefile @@ -30,6 +30,9 @@ install: test ! -d ~/.config/profile.d/emacs && \ ln -sf -- ~/.dotfiles/emacs/user-profile ~/.config/profile.d/emacs; \ fi + mkdir -p -- ~/.local/bin + test ! -d ~/.local/bin/e + ln -sf -- "$$(which emacs)" ~/.local/bin/e uninstall: -unlink -- ~/.config/profile.d/emacs @@ -37,5 +40,6 @@ uninstall: -unlink -- ~/.config/emacs/init.el -unlink -- ~/.emacs.d -rmdir -- ~/.config/emacs + -unlink -- ~/.local/bin/e .PHONY: install uninstall diff --git a/git/Makefile b/git/Makefile index 3f9f161..13c3740 100644 --- a/git/Makefile +++ b/git/Makefile @@ -7,11 +7,15 @@ install: mkdir -p -- ~/.config/bash/aliases.d test ! -d ~/.config/bash/aliases.d/git ln -sf -- ~/.dotfiles/git/bash-aliases ~/.config/bash/aliases.d/git + $(CHECK_INSTALLED) dash + mkdir -p -- ~/.local/bin + ln -sf -- ~/.dotfiles/git/ge ~/.local/bin/ uninstall: -unlink -- ~/.config/git/config -rmdir -- ~/.config/git -unlink -- ~/.config/bash/aliases.d/git -rmdir -- ~/.config/bash/aliases.d + -unlink -- ~/.local/bin/ge .PHONY: install uninstall diff --git a/git/ge b/git/ge new file mode 100755 index 0000000..4c703e0 --- /dev/null +++ b/git/ge @@ -0,0 +1,8 @@ +#!/bin/dash + +e "$@" +git add -- "$@" + +if test -f "$(git home)/.git/autosave"; then + exec git commit -m 'Autosave' +fi diff --git a/gnupg/Makefile b/gnupg/Makefile index 6583b2d..76f83e9 100644 --- a/gnupg/Makefile +++ b/gnupg/Makefile @@ -13,10 +13,18 @@ install: mkdir -p -- ~/.config/profile.d test ! -d ~/.config/profile.d/gnupg ln -sf -- ~/.dotfiles/gnupg/user-profile ~/.config/profile.d/gnupg + $(CHECK_INSTALLED) dash + mkdir -p -- ~/.local/bin + ln -sf -- ~/.dotfiles/gnupg/decrypt ~/.local/bin/ + ln -sf -- ~/.dotfiles/gnupg/encrypt ~/.local/bin/ + ln -sf -- ~/.dotfiles/gnupg/encrypt-nosign ~/.local/bin/ uninstall: -unlink -- ~/.config/profile.d/gnupg -rmdir -- ~/.config/profile.d -unlink -- ~/.var/lib/gnupg + -unlink -- ~/.local/bin/decrypt + -unlink -- ~/.local/bin/encrypt + -unlink -- ~/.local/bin/encrypt-nosign .PHONY: install uninstall diff --git a/gnupg/decrypt b/gnupg/decrypt new file mode 100755 index 0000000..57db255 --- /dev/null +++ b/gnupg/decrypt @@ -0,0 +1,13 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;31m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exit 1 +else + for file in "$@"; do + if test "${file}" = "${file%*.crypt}"; then + gpg --decrypt < "${file}" > "${file%*.crypt}" + else + gpg --decrypt < "${file}" > "${file}.decrypted" + fi + done +fi diff --git a/gnupg/encrypt b/gnupg/encrypt new file mode 100755 index 0000000..e91190f --- /dev/null +++ b/gnupg/encrypt @@ -0,0 +1,10 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;34m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exit 1 +else + for file in "$@"; do + gpg --encrypt --sign -r "${GPG_KEY}" -u "${GPG_KEY}" < "${file}" > "${file}.crypt" + done + printf '\033[1;34m%s\033[0m\n' '-- Do not forget to shred. --' >&2 +fi diff --git a/gnupg/encrypt-nosign b/gnupg/encrypt-nosign new file mode 100755 index 0000000..c4446b1 --- /dev/null +++ b/gnupg/encrypt-nosign @@ -0,0 +1,10 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;31m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exec 1 +else + for file in "$@"; do + gpg --encrypt -r "${GPG_KEY}" < "${file}" > "${file}.crypt" + done + printf '\033[1;34m%s\033[0m\n' '-- Do not forget to shred. --' >&2 +fi -- cgit v1.2.3-70-g09d2