Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
git + gitolite shell access, user-based
#!/bin/bash
shift # get rid of -c
# if no commands, just open a shell
if [[ $# -eq 0 ]]; then
/bin/bash -l
# if the first arg is a git- command, that means it is something like git-push, etc... so forward it
elif [[ $1 == git-* ]]; then
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@localhost $*
# if the first arg is SET_ENV_ONLY, we sourced this file in order to set up the gitolite function
elif [[ $1 == "SET_ENV_ONLY" ]]; then
gitolite () {
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@localhost $*
}
# if there is at least one non-git command, source this file in a new shell and create the 'gitolite' function
else
/bin/bash -c "source $0 shiftme SET_ENV_ONLY; $*"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment