bin/homedir-setup

changeset 967
9314317ed18f
parent 966
e1132c1cce12
child 969
28111ba4e573
equal deleted inserted replaced
966:e1132c1cce12 967:9314317ed18f
1 #!/bin/bash 1 #!/bin/bash
2 set -euo pipefail 2 set -euo pipefail
3 3
4 if [ ! -f .zshrc ]; then 4 warn() { echo "$*" >&2; }
5 echo "Refusing to run without a .zshrc nearby" >&2 5 die() { warn "$*"; exit 1; }
6 exit 1
7 fi
8
9 if ! git --version >/dev/null; then
10 echo "Please install git!" >&2
11 exit 1
12 fi
13 6
14 clone_or_pull() { 7 clone_or_pull() {
15 if ! [ -d $2 ]; then 8 if ! [ -d $2 ]; then
16 git clone --single-branch --depth 1 "$1" $2 9 git clone --single-branch --depth 1 "$1" $2
17 else 10 else
18 echo "$2:" 11 echo "$2:"
19 git -C "$2" pull 12 git -C "$2" pull
20 fi 13 fi
21 } 14 }
15
16 [ -f .zshrc ] ||
17 die "Refusing to run without a .zshrc nearby"
18
19 git --version >/dev/null ||
20 die "Please install git!"
22 21
23 clone_or_pull 'https://github.com/tarjoilija/zgen.git' .zgen 22 clone_or_pull 'https://github.com/tarjoilija/zgen.git' .zgen
24 23
25 zsh -i -c 'zgen update' || : 24 zsh -i -c 'zgen update' || :
26 25
33 bin/setup-man || : 32 bin/setup-man || :
34 33
35 # Get rid of older stuff 34 # Get rid of older stuff
36 for OLD in .plenv .rbenv .ndenv; do 35 for OLD in .plenv .rbenv .ndenv; do
37 if [ -e $OLD ]; then 36 if [ -e $OLD ]; then
38 echo "Pruning $OLD" >&2 37 warn "Pruning $OLD"
39 rm -rf $OLD 38 rm -rf $OLD
40 fi 39 fi
41 done 40 done

mercurial