dotfiles

Alpine Linux dotfiles

git clone git://git.lin.moe/dotfiles.git

 1#!/usr/bin/env sh
 2
 3: ${RGIT_CONTROL_PATH:="$HOME/.ssh/controlmaster/rgit"}
 4: ${RGIT_INSTANCE:="ssh://git.lin.moe"}
 5
 6[ -d $(dirname $RGIT_CONTROL_PATH) ] || mkdir $(dirname $RGIT_CONTROL_PATH)
 7if [ ! -S $RGIT_CONTROL_PATH ]; then
 8	ssh -f -N \
 9	    -o ExitOnForwardFailure=yes \
10	    -o ControlMaster=auto \
11	    -o ControlPath="$RGIT_CONTROL_PATH" \
12	    -o ControlPersist=1h \
13	    $RGIT_INSTANCE
14fi
15
16_quoted_args(){
17	echo -n "'$1'"
18	shift
19	for arg in "$@"; do
20		arg=$(echo $arg | sed "s/'/'\"'\"'/g")
21		echo -n " '$arg'"
22	done
23}
24
25ssh -o ControlMaster=auto \
26    -o ControlPath="$RGIT_CONTROL_PATH" \
27    -T $RGIT_INSTANCE "$(_quoted_args "$@")"