Last active
July 10, 2019 09:58
-
-
Save nicola-strappazzon/af873f14461e643c7f7a3493b83d8cd6 to your computer and use it in GitHub Desktop.
Send local env variables to server through by ssh
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
_ssh_completions() | |
{ | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-) | |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | |
} | |
complete -F _ssh_completions s | |
s() { | |
if [ -n "${1}" ] ; then | |
MYSQL_USER=root | |
MYSQL_PASSWORD= | |
case $1 in | |
*-stg-*) MYSQL_PASSWORD=foo ;; | |
*-sbx-*) MYSQL_PASSWORD=bar ;; | |
*-prd-*) MYSQL_PASSWORD=baz ;; | |
esac | |
/usr/bin/ssh $1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment