Skip to content

Instantly share code, notes, and snippets.

@bhaettasch
Created October 9, 2018 16:46
Show Gist options
  • Save bhaettasch/deb8af5b7f2566c317211ba7c9db8181 to your computer and use it in GitHub Desktop.
Save bhaettasch/deb8af5b7f2566c317211ba7c9db8181 to your computer and use it in GitHub Desktop.
Automatically deploy your local bash aliases to a remote host on ssh connection
# Autocompletion
complete -W "$(cat ~/.ssh/config | grep Host | awk '{ print $2 }')" ssh-a
#!/bin/bash
set -o errexit
set -o nounset
echo "Home sweet home - preparing"
scp ~/.bash_aliases "$1:.my_bash_aliases" >/dev/null
set +o errexit
ssh "$1" "grep 'source .my_bash_aliases' .bashrc || echo 'source .my_bash_aliases' >>.bashrc" >/dev/null
set -o errexit
ssh "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment