diff --git a/meta/git-remote b/meta/git-remote new file mode 100755 index 0000000..29eaf26 --- /dev/null +++ b/meta/git-remote @@ -0,0 +1,16 @@ +#!/bin/sh + +die() { + printf "$1" >&2 + exit ${2:-1} +} + +remote="$(git remote get-url origin)" +! grep -q '^git@' <<<"$remote" || die "Using ssh already.\n" 0 + +host="$(cut -d/ -f3 <<<"$remote")" +grep -q "$host" "$HOME"/.ssh/known_hosts || die "No ssh key for $host found.\n" + +ssh_remote="$(sed 's_^https\?://_git@_;s_/_:_' <<<"$remote")" +git remote set-url origin "$ssh_remote" +die "Set origin remote url to $ssh_remote\n" $? diff --git a/meta/install.conf.yaml b/meta/install.conf.yaml index 52831bc..2c2f92e 100644 --- a/meta/install.conf.yaml +++ b/meta/install.conf.yaml @@ -1,4 +1,11 @@ - shell: + - + command: chsh -s /usr/bin/zsh + description: Changing login shell to zsh + - + command: meta/git-remote + description: Updating git remote to use ssh + stderr: true - command: meta/submodules --init description: Pulling all submodules