dotfiles / .bashrc.d / 10_ssh.sh

#/bin/bash

if [ "${UNAME}" != "SunOS" ]; then
	AGENT_FILE=$HOME/.ssh-agent.sh
	if ps aux | awk -v USER=$(id -un) -v UID=$(id -u) 'BEGIN {exitcode=0}; ($1 ~ USER || $1 ~ UID) && $0 ~ "ssh-agent" && $0 !~ "awk" && $0 !~ "<defunct>" {exitcode++}; END {exit exitcode}'; then
	    rm -f $AGENT_FILE
	    ssh-agent | grep -v echo >&$AGENT_FILE
	fi

	sss() {
	# Solaris specific ssh, we want a terminal environment that is understod on said platform.

	    TERM=xterm ssh "$@"

	}

	shopt -u hostcomplete && AddArrayCompletion _ssh sss

	if [[ -n "${SSH_AUTH_SOCK}" && -n "${SSH_AGENT_PID}" ]]; then
		if ! Quiet grep -F "${SSH_AUTH_SOCK}" "${AGENT_FILE}" || \
		   ! Quiet grep -F "${SSH_AGENT_PID}" "${AGENT_FILE}"; then
			cat <<EOS >$AGENT_FILE 
SSH_AUTH_SOCK=${SSH_AUTH_SOCK}; export SSH_AUTH_SOCK;
SSH_AGENT_PID=${SSH_AGENT_PID}; export SSH_AGENT_PID;
EOS
		fi
	fi

	AddRc $AGENT_FILE
fi
# EOF
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.