From 99a687a31546261380a4cd33e8ed2487d8149cf6 Mon Sep 17 00:00:00 2001 From: lhark Date: Tue, 28 Jun 2016 04:22:35 +0200 Subject: [PATCH] Gitconfig user template autofill and automatic checkinstall --- .gitignore | 1 + git_user.def | 4 ++++ gitconfig | 5 ++--- install.sh | 16 +++++++++++----- zshrc | 10 ++++++---- 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 git_user.def diff --git a/.gitignore b/.gitignore index b6633fc..28b2b38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vim/.netrwhist vim/bundle/* +git_user diff --git a/git_user.def b/git_user.def new file mode 100644 index 0000000..2fe8e4e --- /dev/null +++ b/git_user.def @@ -0,0 +1,4 @@ +[user] + name = {username} + email = {email} + diff --git a/gitconfig b/gitconfig index a14d899..3eb316a 100644 --- a/gitconfig +++ b/gitconfig @@ -1,8 +1,7 @@ [core] excludesfile = ~/.gitignore_global -[user] - name = lhark - email = lhark@hotmail.fr +[include] + path = ~/.git_user [master] autosetuprebase = always [color] diff --git a/install.sh b/install.sh index 5b9fbcb..e93d53d 100755 --- a/install.sh +++ b/install.sh @@ -2,17 +2,23 @@ SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") +HOST=`hostname` # List of the config files to install -FILES="vimrc zshrc gitconfig vim gitignore_global" +FILES="vimrc zshrc gitconfig vim gitignore_global git_user" + +if [[ ! $1 == "--check" ]] +then + cp $SCRIPTPATH/git_user.def $SCRIPTPATH/git_user + sed -i -e "s/{username}/$USER/" $SCRIPTPATH/git_user + sed -i -e "s/{email}/$USER@$HOST/" $SCRIPTPATH/git_user +fi # Create symbolic links in the user's home dir -cd $HOME for file in $FILES do - if [ ! -f .${file} ] + if [ ! -e $HOME/.${file} ] then - ln -s ${SCRIPTPATH}/${file} .${file} + ln -s ${SCRIPTPATH}/${file} $HOME/.${file} fi done -cd - diff --git a/zshrc b/zshrc index a883951..cd6abb8 100644 --- a/zshrc +++ b/zshrc @@ -18,7 +18,7 @@ RC_PATH=$(dirname "$(readlink -f ${(%):-%x})") # Mise à jour automatique à partir du repo distant -pushd > /dev/null 2>&1 +PWD=`pwd` cd $RC_PATH # In case the network is down, don't lock the terminal @@ -37,13 +37,15 @@ elif $(echo "$git_st" | grep '^## .*behind' &> /dev/null); then echo "Type Y to update .zshrc: \c" read line if [ "$line" = Y ] || [ "$line" = y ]; then - git pull --rebase --stat origin master && source $HOME/.zshrc - popd > /dev/null 2>&1 + git pull --rebase --stat origin master + ./install.sh --check + cd $PWD + source $HOME/.zshrc return fi fi -popd > /dev/null 2>&1 +cd $PWD # Configuration for virtualenv