diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2008-10-29 03:50:18 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2008-10-29 03:50:18 +0100 |
commit | 0cfdb493f045e7c533328617427a7416783c28b5 (patch) | |
tree | cc9a1a43343cef6550357eab1e25a1923dae627b | |
parent | 4e4fb8d5d790d2cc6eabab95aaea4b81225ca164 (diff) | |
download | dotfiles-0cfdb493f045e7c533328617427a7416783c28b5.tar.gz dotfiles-0cfdb493f045e7c533328617427a7416783c28b5.tar.xz dotfiles-0cfdb493f045e7c533328617427a7416783c28b5.zip |
added bashrc configdir
added git config
-rw-r--r-- | bashrc/common/alias.sh | 29 | ||||
-rw-r--r-- | bashrc/common/bashcomp.sh | 20 | ||||
-rw-r--r-- | bashrc/common/color.sh | 42 | ||||
-rw-r--r-- | bashrc/common/dircolors.sh | 4 | ||||
-rw-r--r-- | bashrc/common/env.sh | 5 | ||||
-rw-r--r-- | bashrc/common/locale.sh | 5 | ||||
-rw-r--r-- | bashrc/common/pager.sh | 13 | ||||
-rw-r--r-- | bashrc/common/shopt.sh | 23 | ||||
-rw-r--r-- | bashrc/dist/init.sh | 13 | ||||
-rw-r--r-- | bashrc/main.sh | 90 | ||||
-rw-r--r-- | bashrc/node/init.sh | 3 | ||||
-rw-r--r-- | gitconfig | 8 |
12 files changed, 255 insertions, 0 deletions
diff --git a/bashrc/common/alias.sh b/bashrc/common/alias.sh new file mode 100644 index 0000000..03df556 --- /dev/null +++ b/bashrc/common/alias.sh @@ -0,0 +1,29 @@ +# command aliases + +# ls helpers +alias ll="ls -l" +alias la="ls -la" +alias l="ls -lh" + +# cd helpers +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." + +# make default what should be default +alias sudo="sudo -H" + +# mkdir + chdir +mkcd() { + mkdir -p $1 && cd $1 +} + +# create tarball of one directory +mktar() { + [[ -z "$1" ]] && return 1 + tar cjvf "${1%%/}.tar.bz2" "${1%%/}/" +} + +# rar -> unrar +alias rar=unrar + diff --git a/bashrc/common/bashcomp.sh b/bashrc/common/bashcomp.sh new file mode 100644 index 0000000..48d83fa --- /dev/null +++ b/bashrc/common/bashcomp.sh @@ -0,0 +1,20 @@ +# bash completion + +bmajor=${BASH_VERSION%%.*} +bminor=${BASH_VERSION#*.} +bminor=${bminor//[^0-9]*} + +if [[ ${bmajor} -eq 2 && ${bminor} -gt 4 ]] || [[ ${bmajor} -gt 2 ]]; then + [[ -f /etc/bash_completion ]] && source /etc/bash_completion + + if [[ -d ~/.bash_completion.d ]]; then + for i in ~/.bash_completion.d/*; do + [[ -f ${i} ]] && source ${i} + done + fi +fi + +unset bmajor bminor + +export COMP_WORDBREAKS=${COMP_WORDBREAKS/:/} +export FIGNORE=".o:~" diff --git a/bashrc/common/color.sh b/bashrc/common/color.sh new file mode 100644 index 0000000..ca62988 --- /dev/null +++ b/bashrc/common/color.sh @@ -0,0 +1,42 @@ +# color code definitions + +# print ugly color codes +coco() { + [[ -z "$1" ]] && echo -ne "\033[0m" || echo -ne "\033[${1}m" +} + +# name all colors to get rid of hieroglyphics +color() { + case $1 in + black) coco '0;30' ;; + dgray) coco '1;30' ;; + red) coco '0;31' ;; + lred) coco '1;31' ;; + green) coco '0;32' ;; + lgreen) coco '1;32' ;; + brown) coco '0;33' ;; + yellow) coco '1;33' ;; + blue) coco '0;34' ;; + lblue) coco '1;34' ;; + purple) coco '0;35' ;; + lpurple) coco '1;35' ;; + cyan) coco '0;36' ;; + lcyan) coco '1;36' ;; + lgray) coco '0;37' ;; + white) coco '1;37' ;; + *) coco '0' ;; + esac +} + +pcolor() { + echo -ne "\[$(color $@)\]" +} + +colors() { + local l="black dgray red lred green lgreen brown yellow blue" + local l="${l} lblue purple lpurple cyan lcyan lgray white" + + for i in $l; do + echo "$i = $(color $i)$i$(color)" + done +} diff --git a/bashrc/common/dircolors.sh b/bashrc/common/dircolors.sh new file mode 100644 index 0000000..f26a163 --- /dev/null +++ b/bashrc/common/dircolors.sh @@ -0,0 +1,4 @@ +# colored output for ls +if hash dircolors; then + eval $(dircolors -b) +fi diff --git a/bashrc/common/env.sh b/bashrc/common/env.sh new file mode 100644 index 0000000..e02e6ad --- /dev/null +++ b/bashrc/common/env.sh @@ -0,0 +1,5 @@ +# force sane editor +export EDITOR=/usr/bin/nano + +# set timezone if needed +[[ -z "$TZ" ]] && export TZ=Europe/Berlin diff --git a/bashrc/common/locale.sh b/bashrc/common/locale.sh new file mode 100644 index 0000000..97c3f17 --- /dev/null +++ b/bashrc/common/locale.sh @@ -0,0 +1,5 @@ +# find a usuable locale + +eval unset ${!LC_*} LANG +export LANG="en_US.UTF-8" +export LC_COLLATE="C" diff --git a/bashrc/common/pager.sh b/bashrc/common/pager.sh new file mode 100644 index 0000000..a92031e --- /dev/null +++ b/bashrc/common/pager.sh @@ -0,0 +1,13 @@ +# pager options + +# use less by default ... +if hash less; then + export PAGER=less + export LESS="-R --ignore-case --long-prompt" +fi + +# but user most, if available +if hash most; then + export PAGER=most + export MANPAGER=most +fi diff --git a/bashrc/common/shopt.sh b/bashrc/common/shopt.sh new file mode 100644 index 0000000..07a796a --- /dev/null +++ b/bashrc/common/shopt.sh @@ -0,0 +1,23 @@ +# bash configuration + +# basic search path for chdir +export CDPATH=".:~" + +# keep size of history small ... +export HISTCONTROL="ignoreboth:erasedups" + +# ... but keep a lot of history +export HISTFILESIZE=5000 +export HISTSIZE=5000 + +# save timestamp in history +export HISTTIMEFORMAT="%+ " + +# check window size after each command +shopt -s checkwinsize + +# save multi-line command as one line +shopt -s cmdhist + +# append history +shopt -s histappend diff --git a/bashrc/dist/init.sh b/bashrc/dist/init.sh new file mode 100644 index 0000000..4dd4ed1 --- /dev/null +++ b/bashrc/dist/init.sh @@ -0,0 +1,13 @@ +# get distribution specific data + +_DISTNAME="unknown" + +if [[ -f /etc/gentoo-release ]]; then + _DISTNAME="gentoo" +elif [[ -f /etc/debian_version ]] ; then + _DISTNAME="debian" +fi + +declare -r _DISTNAME + +_load dist common 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} diff --git a/bashrc/node/init.sh b/bashrc/node/init.sh new file mode 100644 index 0000000..6bf0924 --- /dev/null +++ b/bashrc/node/init.sh @@ -0,0 +1,3 @@ +# get node specific data + +declare -r _NODENAME=laptop diff --git a/gitconfig b/gitconfig new file mode 100644 index 0000000..f86779d --- /dev/null +++ b/gitconfig @@ -0,0 +1,8 @@ +[user] + name = Alexander Sulfrian + email = alexander@sulfrian.net + +[color] + diff = auto + status = auto + branch = auto |