git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/.gitignore
blob: d049053986b48f82cd208d987d4945729c4a9a66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
*
!/.gitignore
!/.gitmodules
!/.bashrc
!/.bash_profile
!/.bash
/.bash/*
!/.bash/*bash
!/bin
!/bin/*
!/distribute
/distribute/*
!/distribute/.gitkeep
!/distrib.yml
!/.flake8
!/.forbidden_modules
!/.gitconfig
!/.gnupg
!/.gnupg/*
!/Makefile
!/.perlcriticrc
!/.profile
!/.pylintrc
!/README.md
!/tmux-gpakosz
!/tmux-yank
!/.tmux.conf*
!/.vimrc
!/.ssh/config
!/.ssh/config.d/0000-all.conf
ger.Long */
#!/usr/bin/env bash

if [ -z "$SSHENVFILE" ];then
	printf "SSHENVFILE not set, no target for SSH environment variables.\\n" >&2
	exit 1
fi

VERB=1
KILLIT=0
while getopts ":qf" SHOPT;do
	case "$SHOPT" in
		q) VERB=0;;
		f) KILLIT=1;;
		*) printf "WAT\n" >&2;exit 127;;
	esac
done
shift "$(( OPTIND -1 ))"

[ "$VERB" -eq 1 ]&&printf "[....] Starting SSH agent.\\033[s"
ROEDGROED="$(pgrep -U "$(whoami)" ssh-agent|grep -v grep|awk '{print $1}')"

if [ -n "$ROEDGROED" ];then
	if [ "$KILLIT" -eq 1 ];then
		for i in $(echo "$ROEDGROED");do kill "$i" >/dev/null 2>&1||break;done
		case "$?" in
			0);;
			*)
				[ "$VERB" -eq 1 ]&&printf "\\033[666D[\\033[31mFAIL\\033[0m]\\033[u\\033[K\\n"
				exit 2
			;;
		esac
	else
		[ "$VERB" -eq 1 ]&&printf "\\033[666D[\\033[30;1mSKIP\\033[0m]\\033[u\\033[K (running, PID: %s)\\n" "$ROEDGROED"
		exit 0
	fi
fi
ssh-agent >"$SSHENVFILE" 2>&1&&chmod 0600 "$SSHENVFILE" >/dev/null 2>&1
case "$?" in
	0)
		sed -i 's/^echo[^\;]*\;//g' "$SSHENVFILE" >/dev/null 2>&1
		[ "$VERB" -eq 1 ]&&printf "\\033[666D[\\033[32m OK \\033[0m]\\033[u\\033[K\\n"
		exit 0
	;;
	*)
		[ "$VERB" -eq 1 ]&&printf "\\033[666D[\\033[31mFAIL\\033[0m]\\033[u\\033[K\\n"
		exit 1
	;;
esac