1
0
mirror of https://github.com/aquatix/dotfiles.git synced 2025-12-06 20:35:11 +01:00

Support ssh config.d, generating ~/.ssh/config from files in ~/.ssh/config.d/, preserving order

This commit is contained in:
2015-08-03 12:58:36 +02:00
parent 719edb27bc
commit 4a25fd0cec

15
.bashrc
View File

@@ -166,6 +166,21 @@ xterm*|rxvt*)
;;
esac
# SSH config merge
#mkdir -p ~/.ssh/config.d/
if [ -e ~/.ssh/config.d ]; then
#if find ~/.ssh/config.d -mindepth 1 -print -quit | grep -q .; then
if find ~/.ssh/config.d -print -quit | grep -q .; then
#newestconfig=$(ls -t ~/.ssh/config.d/ | head -1)
newestconfig=$(find ~/.ssh/config.d/* -printf '%T+ %p\n' | sort -r | head -n1 | awk '{print $2}')
if [ "$newestconfig" -nt ~/.ssh/config ]; then
[ -e ~/.ssh/config ] && mv ~/.ssh/config ~/.ssh/config.bak.$(date -Ins)
#cat ~/.ssh/config.d/* > ~/.ssh/config
find ~/.ssh/config.d/* -type f -print0 | sort -z | xargs -0 -n1 cat > ~/.ssh/config
fi
fi
fi
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.