Last active
January 2, 2016 11:59
-
-
Save james-huston/8300742 to your computer and use it in GitHub Desktop.
Some bash alias trickery for firing up ssh-agent and adding your keys on a mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bash_profile | |
# Get the aliases and functions | |
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi | |
PATH=$PATH:$HOME/bin | |
# source ~/.profile, if available | |
if [[ -r ~/.profile ]]; then | |
. ~/.profile | |
fi | |
agent_started=0 | |
if ! env | grep -q SSH_AGENT_PID >/dev/null; then | |
echo "Starting ssh agent" | |
eval $(ssh-agent -s) | |
agent_started=1 | |
fi | |
function deploy() { | |
if ! ssh-add -l >/dev/null 2>&-; then | |
ssh-add ~/.ssh/id_rsa | |
fi | |
/path/to/deploy "$@" | |
} | |
export -f deploy | |
function ssh() { | |
if ! ssh-add -l >/dev/null 2>&-; then | |
ssh-add ~/.ssh/id_rsa | |
fi | |
/usr/bin/ssh "$@" | |
} | |
export -f ssh | |
function git() { | |
if ! ssh-add -l >/dev/null 2>&-; then | |
ssh-add ~/.ssh/id_rsa | |
fi | |
/usr/bin/git "$@" | |
} | |
export -f git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment