summaryrefslogtreecommitdiffstats
path: root/bashrc/main.sh
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2008-10-29 03:50:18 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2008-10-29 03:50:18 +0100
commit0cfdb493f045e7c533328617427a7416783c28b5 (patch)
treecc9a1a43343cef6550357eab1e25a1923dae627b /bashrc/main.sh
parent4e4fb8d5d790d2cc6eabab95aaea4b81225ca164 (diff)
downloaddotfiles-0cfdb493f045e7c533328617427a7416783c28b5.tar.gz
dotfiles-0cfdb493f045e7c533328617427a7416783c28b5.tar.xz
dotfiles-0cfdb493f045e7c533328617427a7416783c28b5.zip
added bashrc configdir
added git config
Diffstat (limited to 'bashrc/main.sh')
-rw-r--r--bashrc/main.sh90
1 files changed, 90 insertions, 0 deletions
diff --git a/bashrc/main.sh b/bashrc/main.sh
new file mode 100644
index 0000000..649641c
--- /dev/null
+++ b/bashrc/main.sh
@@ -0,0 +1,90 @@
+# this file is sourced by all bash shells on startup
+
+# test for interactive shell
+[[ $- != *i* ]] && return
+
+declare -r _DOTFILES_DIR="${HOME}/.dotfiles"
+declare -r _BASHRC_DIR="${_DOTFILES_DIR}/bashrc"
+
+# self update magic
+_self_update() {
+ pushd ${_DOTFILES_DIR} &>/dev/null
+
+ if [[ -n "$(git fetch 2>&1)" && $? -eq 0 ]]; then
+ echo -ne "\033[31m*\033[0m dotfile updates found, merge now? "
+
+ if read; then
+ git merge origin/master
+ popd &>/dev/null
+ exec $SHELL
+ fi
+ fi
+
+ popd &>/dev/null
+}
+
+# module load magic
+_load() {
+ local base path
+ local pedantic=0
+
+ [[ -z $1 || -z $2 ]] && return
+
+ base=${_BASHRC_DIR}/${1}
+
+ if [[ $1 == "common" || $2 == "init" ]]; then
+ path=${2}.sh
+ pedantic=1
+ else
+ case $1 in
+ (dist) path=${_DISTNAME}/${2}.sh ;;
+ (node) path=${_NODENAME}/${2}.sh ;;
+ esac
+ fi
+
+ if [[ -r ${base}/${path} ]]; then
+ source ${base}/${path}
+ elif [[ ${pedantic} -eq 1 ]]; then
+ echo "error: cannot find necessary startup file: ${base}/${path}"
+ fi
+}
+
+# update first
+_self_update
+
+# locale should be set first
+_load common locale
+
+# now set a reasonable environment
+_load common env
+
+# bash configuration
+_load common shopt
+
+# load internals
+_load dist init
+_load node init
+
+# command aliases
+_load common alias
+
+# pager options
+_load common pager
+
+# color code definitions
+_load common color
+
+# colored output for ls
+_load common dircolors
+
+# command prompt
+#_load common prompt
+
+# bash completion
+_load common bashcomp
+
+# load common distribution settings
+_load dist common
+
+# load distribution specific node settings
+_load node ${_DISTNAME}