Commits

Mario Fuest committed edd48d9

Initial getting/setting dotfiles scripts (needs some tests though)

Comments (0)

Files changed (5)

+# General
+passwords
+backups/*
+
+# Strange dotfiles
 .vim/.netrwhist
+.swo
+#! /bin/bash
+# basedotfiles
+# sourced by set/get dotfiles
+
+# CONSTANTS
+DOTFILEDIR=~/dev/dotfiles
+PASSWDFILE=~/dev/dotfiles/passwords
+BACKUPDIR=~/dev/dotfiles/backup
+
+# passwd function
+getPasswd() { awk '/^'"${1}"'/{print $2}' ${PASSWDFILE}; }
+
+# Remove backupfiles
+# TODO: Use single regex
+rm_bkpfiles() {
+    find ${DOTFILEDIR} -type f -name "*.bak" -exec rm -f {} \;
+    find ${DOTFILEDIR} -type f -name "*-bak" -exec rm -f {} \;
+    find ${DOTFILEDIR} -type f -name "*~" -exec rm -f {} \;
+    find ${DOTFILEDIR} -type f -name "*.swp" -exec rm -f {} \;
+    find ${DOTFILEDIR} -type f -name "*.orig" -exec rm -f {} \;
+}
+
+# Files
+# Do not(!) use files with spaces
+files=(
+    ~/.bashrc             #  0
+    ~/.aliases            #  1
+    ~/.inputrc            #  2
+    ~/.xinitrc            #  3
+    ~/.Xdefaults          #  4
+    ~/.Xmodmap            #  5
+    ~/.vimrc              #  6
+    ~/.weechat/\*.conf    #  7
+    ~/.ncmpcpp/config     #  8
+    ~/.bin/colortest      #  9
+    ~/.bin/mplayer        # 10
+    ~/.bin/lodgeit.py     # 11
+    ~/.config/awesome/\*  # 12
+    ~/.vim/               # 13
+    
+)
+
+declare -a fileDirs
+fileDirs[7]=.weechat
+fileDirs[8]=.ncmpcpp
+fileDirs[9]=.bin
+fileDirs[10]=.bin
+fileDirs[11]=.bin
+fileDirs[12]=awesome-config
+
+# Passwords etc.
+# Shall not contain spaces!
+declare -a pwds
+pwds=(
+    BouncerDomain         # 0
+    BouncerPasswd         # 1
+)
+declare -a pwdFiles
+pwdFiles[0]=.weechat/irc.conf
+pwdFiles[1]=.weechat/irc.conf
+#! /bin/bash
+# Update from repo to local
+
+# source
+DOTFILEDIR=~/dev/dotfiles
+. ${DOTFILEDIR}/basedotfiles
+
+# At first: Backup!
+mkdir -p ${BACKUPDIR}
+for ((i=0; i<${#files[@]}; i++)); do
+    cp -R -t ${BACKUPDIR}/${fileDirs[$i]} ${files[$i]} 
+done
+
+# Copy back
+# TODO: Find nicer solution!
+# 1. Remove backup files
+rm_bkpfiles
+# 2. Copy dotfiles (except awesome and hg)
+find ${DOTFILEDIR} . \( -name '.*' ! -name '.hg*' \) -exec cp -R -f {} ~ \;
+# 3. Copy awesome
+cp -R -f ${DOTFILEDIR}/awesome-config/* ~/.config/awesome/

passwords_example

+# Amend last column!
+BouncerDomain BouncerDomain
+BouncerPasswd BouncerPasswd
+#! /bin/bash
+# Update from local to repo
+
+# Source
+DOTFILEDIR=~/dev/dotfiles
+. ${DOTFILEDIR}/basedotfiles
+
+# Maybe some files have been deleted?
+# if [ -e ${DOTFILEDIR}/.vim ]; then rm -rf ${DOTFILEDIR}/.vim; fi
+# if [ -e ${DOTFILEDIR}/.irssi ]; then rm -rf ${DOTFILEDIR}/.irssi; fi
+# if [ -e ${DOTFILEDIR}/awesome-config ]; then rm -rf ${DOTFILEDIR}/awesome-config; fi
+# if [ -e ${DOTFILEDIR}/.weechat ]; then rm -rf ${DOTFILEDIR}/.weechat; fi
+
+# Some dir creations and removements
+mkdir -p ${DOTFILEDIR}/awesome-config
+mkdir -p ${DOTFILEDIR}/.weechat
+if [ -e ${DOTFILEDIR}/.vim/.netrwhist ]; then
+    rm ${DOTFILEDIR}/.vim/.netrwhist
+fi
+mkdir -p ${DOTFILEDIR}/.bin
+mkdir -p ${DOTFILEDIR}/.ncmpcpp
+
+# Copy!
+for ((i=0; i<${#files[@]}; i++)); do
+    cp -R -t ${DOTFILEDIR}/${fileDirs[$i]} ${files[$i]} 
+done
+
+# FIXME: Bad hack!
+# hg does not like empty dirs
+for lang in python lua perl ruby; do
+    if [ `find ~/.weechat/${lang} -type f` ]; then
+        cp -R ~/.weechat/${lang} ${DOTFILEDIR}/.weechat
+    fi
+done
+
+# Remove backup files
+rm_bkpfiles
+
+# Take care for passwds etc.:
+for ((i=0; i<${#pwds[@]}; i++)); do
+    sed -i "s/`getPasswd ${pwds[$i]}`/${pwds[$i]}/" "${pwdFiles[$i]}"
+done