From 021d2df326adba6fe9c028d65d1445a28753773e Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 8 Sep 2020 11:18:49 +0800 Subject: update --- tools/init/check_upstream | 24 ++++++++++++++++++++++++ tools/init/load-settings.sh | 31 +++++++++++++++++++++++++++++++ tools/init/sync.sh | 11 +++++++++++ 3 files changed, 66 insertions(+) create mode 100755 tools/init/check_upstream create mode 100755 tools/init/load-settings.sh create mode 100755 tools/init/sync.sh (limited to 'tools/init') 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 @@ +#! /bin/bash + +# This script is for repo forked from others +# check $1(repo) if upstream branch origin/master is +# ahead of local branch $2(default to dev) + +if [ ! -d "$1" ]; then + return 0 +fi + +head='dev' +if [ $# -eq 2 ] +then + head=$2 +fi + +cd "$1" && \ +git fetch origin && \ +if ! git rev-list "$head" | grep "$(git rev-parse origin/master)" > /dev/null; then + [[ $(git pull my) == 'Alrady up to date.' ]] || \ + echo "New commit at" "$1" +fi + +echo "$(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 @@ +if [[ $0 == 'zsh' ]]; then + setopt extended_glob +elif [[ $0 == 'bash' ]]; then + shopt -s extglob +fi + +# set default editor +export EDITOR=vim + +# load custom aliases +SETTING_DIR=${SETTING_DIR:=$HOME/settings} +source $SETTING_DIR/alias + +# Add custom scripts into PATH +BIN_DIR=$HOME/bin +PATH=$PATH:$BIN_DIR +mkdir -p $BIN_DIR +find $BIN_DIR -xtype l | xargs rm 2>/dev/null || true + +find $SETTING_DIR/tools -type f -executable | \ +xargs realpath | xargs -I{} ln -sf {} $BIN_DIR + +# load custom functions +OSM_UTIL_DIR=$SETTING_DIR/tools/osm +source $OSM_UTIL_DIR/osm + +# sync with important git repos +$SETTING_DIR/tools/init/sync.sh + +# go +PATH=$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 @@ +#!/bin/bash + +# my repo +cd $SETTING_DIR && git pull --quiet || echo in `pwd` > /dev/tty & +if [ -d ~/vimwiki ]; then + cd ~/vimwiki && git pull --quiet || echo in `pwd` > /dev/tty & +fi + +# others repo +check_upstream ~/git/tig || echo in `pwd` > /dev/tty & +check_upstream ~/.vim_runtime || echo in `pwd` > /dev/tty & -- cgit v1.2.3-70-g09d2