diff --git a/.bashrc b/.bashrc index 0c685d9..06376d4 100644 --- a/.bashrc +++ b/.bashrc @@ -146,8 +146,7 @@ if ! shopt -oq posix; then fi # Customizations - -if [ -f ~/.profile ]; then +if [ -f ~/.profile ] && [ -z "${SSH_CONNECTION}" ]; then . ~/.profile fi diff --git a/.zshrc b/.zshrc index 31ae1b4..9251aa9 100644 --- a/.zshrc +++ b/.zshrc @@ -70,6 +70,21 @@ if [ -z "${SUDO_USER}" ] && [ -z "${SSH_CONNECTION}" ] && [ -z "${TERM_PROGRAM}" tmux new -A -s local_tmux fi +# Define a function to use autossh with a custom bashrc +function assh() { + remote_file=$(mktemp) + if $(ssh "$@" "cat > ${remote_file}" < ~/.bashrc > /dev/null 2>&1); then + # Successfully copied bashrc to the remote. Source it upon ssh + autossh -t "$@" "bash --rcfile ${remote_file}; rm ${remote_file}" + else + # SSH Config specifies a RemoteCommand; connect normally + autossh "$@" + fi +} +# Use ssh completion for autossh +compdef autossh=ssh +compdef assh=ssh + # Custom dircolors [ -f ~/.dircolors ] && eval "$(dircolors ~/.dircolors)"