mirror of
https://github.com/aquatix/dotfiles.git
synced 2025-12-06 22:55:10 +01:00
Support ssh config.d, generating ~/.ssh/config from files in ~/.ssh/config.d/, preserving order
This commit is contained in:
15
.bashrc
15
.bashrc
@@ -166,6 +166,21 @@ xterm*|rxvt*)
|
|||||||
;;
|
;;
|
||||||
esac
|
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.
|
# Alias definitions.
|
||||||
# You may want to put all your additions into a separate file like
|
# You may want to put all your additions into a separate file like
|
||||||
# ~/.bash_aliases, instead of adding them here directly.
|
# ~/.bash_aliases, instead of adding them here directly.
|
||||||
|
|||||||
Reference in New Issue
Block a user