Skip to content

Instantly share code, notes, and snippets.

@NikolayMurha
Created August 22, 2013 12:12
Show Gist options
  • Save NikolayMurha/6306404 to your computer and use it in GitHub Desktop.
Save NikolayMurha/6306404 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ! -d "$HOME/bin/ssh" ]
then
[[ -d "$HOME/bin" ]] || mkdir "$HOME/bin"
cp ./ssh $HOME/bin/ssh
grep -q -e "alias ssh='~/bin/ssh'" $HOME/.bash_aliases || echo "alias ssh='~/bin/ssh'" >> $HOME/.bash_aliases
fi
#!/bin/bash
ssh() {
TMPDIR=~/tmp
case "$(uname -s)" in
Linux)
tmp_fifo=$(mktemp -u --suffix=._ssh_fifo)
;;
Darwin)
tmp_fifo=$(mktemp -u -t ._ssh_fifo)
;;
*)
echo 'unsupported OS'
exit
;;
esac
# cleanup first
rm ~/tmp/._ssh_fifo* 2>/dev/null
mkfifo "$tmp_fifo"
cat ~/.ssh/config ~/.ssh/config.* >"$tmp_fifo" 2>/dev/null &
/usr/bin/ssh -F "$tmp_fifo" "$@"
cat "$tmp_fifo"
# rm "$tmp_fifo"
}
ssh $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment