#!/usr/bin/env sh # # Shell common environment variables and functions (BusyBox compatible) # # Favourite commands # And for the rest, see aliases direnv JUNKHOME "$HOME/.cache/junkhome" # SSH Agent # If GPG agent is configured for SSH if grep -q ^enable-ssh-support$ $GNUPGHOME/gpg-agent.conf 2> /dev/null then # Load GPG agent unset SSH_AGENT_PID if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" fi else # Start regular SSH agent if not already started SSH_ENV="$HOME/.ssh/agent" start_agent() { ssh-agent > "${SSH_ENV}" chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null } if [ -f "${SSH_ENV}" ] then . "${SSH_ENV}" > /dev/null if [ ! -d "/proc/${SSH_AGENT_PID}" ] || [ "$(cat "/proc/${SSH_AGENT_PID}/comm")" != "ssh-agent" ] then start_agent fi else start_agent fi fi # TODO Service sytem that works without systemd, # and can stop processes on logout