aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/init
diff options
context:
space:
mode:
Diffstat (limited to 'tools/init')
-rwxr-xr-xtools/init/check_upstream24
-rwxr-xr-xtools/init/load-settings.sh31
-rwxr-xr-xtools/init/sync.sh11
3 files changed, 66 insertions, 0 deletions
diff --git a/tools/init/check_upstream b/tools/init/check_upstream
new file mode 100755
index 0000000..e9e8841
--- /dev/null
+++ b/tools/init/check_upstream
@@ -0,0 +1,24 @@
1#! /bin/bash
2
3# This script is for repo forked from others
4# check $1(repo) if upstream branch origin/master is
5# ahead of local branch $2(default to dev)
6
7if [ ! -d "$1" ]; then
8 return 0
9fi
10
11head='dev'
12if [ $# -eq 2 ]
13then
14 head=$2
15fi
16
17cd "$1" && \
18git fetch origin && \
19if ! git rev-list "$head" | grep "$(git rev-parse origin/master)" > /dev/null; then
20 [[ $(git pull my) == 'Alrady up to date.' ]] || \
21 echo "New commit at" "$1"
22fi
23
24echo "$(date)" check "$1" >> "$SETTING_DIR/log"
diff --git a/tools/init/load-settings.sh b/tools/init/load-settings.sh
new file mode 100755
index 0000000..041941a
--- /dev/null
+++ b/tools/init/load-settings.sh
@@ -0,0 +1,31 @@
1if [[ $0 == 'zsh' ]]; then
2 setopt extended_glob
3elif [[ $0 == 'bash' ]]; then
4 shopt -s extglob
5fi
6
7# set default editor
8export EDITOR=vim
9
10# load custom aliases
11SETTING_DIR=${SETTING_DIR:=$HOME/settings}
12source $SETTING_DIR/alias
13
14# Add custom scripts into PATH
15BIN_DIR=$HOME/bin
16PATH=$PATH:$BIN_DIR
17mkdir -p $BIN_DIR
18find $BIN_DIR -xtype l | xargs rm 2>/dev/null || true
19
20find $SETTING_DIR/tools -type f -executable | \
21xargs realpath | xargs -I{} ln -sf {} $BIN_DIR
22
23# load custom functions
24OSM_UTIL_DIR=$SETTING_DIR/tools/osm
25source $OSM_UTIL_DIR/osm
26
27# sync with important git repos
28$SETTING_DIR/tools/init/sync.sh
29
30# go
31PATH=$PATH:$HOME/go/bin
diff --git a/tools/init/sync.sh b/tools/init/sync.sh
new file mode 100755
index 0000000..00ed4b8
--- /dev/null
+++ b/tools/init/sync.sh
@@ -0,0 +1,11 @@
1#!/bin/bash
2
3# my repo
4cd $SETTING_DIR && git pull --quiet || echo in `pwd` > /dev/tty &
5if [ -d ~/vimwiki ]; then
6 cd ~/vimwiki && git pull --quiet || echo in `pwd` > /dev/tty &
7fi
8
9# others repo
10check_upstream ~/git/tig || echo in `pwd` > /dev/tty &
11check_upstream ~/.vim_runtime || echo in `pwd` > /dev/tty &