Remove ssh with config copy
This commit is contained in:
parent
71131a52b9
commit
7eb46cf63c
34
zshrc
34
zshrc
@ -575,40 +575,6 @@ package_json_read_project() {
|
|||||||
|
|
||||||
add-zsh-hook chpwd package_json_read_project
|
add-zsh-hook chpwd package_json_read_project
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------- Copy zshrc remote -------------------------
|
|
||||||
|
|
||||||
sshc() {
|
|
||||||
local source target
|
|
||||||
source=${ZDOTDIR:-$HOME}
|
|
||||||
target="/tmp/.zdot-${RANDOM}"
|
|
||||||
consolidate-config
|
|
||||||
ssh -q -o "ControlPath=/tmp/.cm-%r@%h:%p" -o "ControlMaster=yes" -o "ControlPersist=yes" $1 'false'
|
|
||||||
ssh -q -o "ControlPath=/tmp/.cm-%r@%h:%p" $1 "mkdir $target"
|
|
||||||
scp -q -o "ControlPath=/tmp/.cm-%r@%h:%p" $source/.zshrc-consolidated $1:$target/.zshrc
|
|
||||||
ssh -q -o "ControlPath=/tmp/.cm-%r@%h:%p" $1 -t "ZDOTDIR=$target exec zsh -l"
|
|
||||||
ssh -q -o "ControlPath=/tmp/.cm-%r@%h:%p" $1 "rm -r $target"
|
|
||||||
ssh -q -o "ControlPath=/tmp/.cm-%r@%h:%p" -O stop $1
|
|
||||||
}
|
|
||||||
|
|
||||||
consolidate-config() {
|
|
||||||
local initial final
|
|
||||||
initial=${ZDOTDIR:-$HOME}/.zshrc
|
|
||||||
final=${ZDOTDIR:-$HOME}/.zshrc-consolidated
|
|
||||||
cp $initial $final
|
|
||||||
while true; do
|
|
||||||
found=$(grep -oP '^source \K.*$' $final)
|
|
||||||
if [[ -z $found ]]; then
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
replaced=${(e)found}
|
|
||||||
if [[ $replaced != /* ]]; then
|
|
||||||
replaced=$(dirname $final)/$replaced
|
|
||||||
fi
|
|
||||||
sed -i "\#^source $found\$# r $replaced${NEWLINE}d" $final
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#---------------------------------- Miscellaneous ----------------------------
|
#---------------------------------- Miscellaneous ----------------------------
|
||||||
|
|
||||||
setopt extended_glob
|
setopt extended_glob
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user