+++ /dev/null
-# Bash configuration file for zucker.schokokeks.org.
-
-
-# Immediately start zsh.
-exec zsh
-
-# vim: ft=sh
source_debug ". ~/.bash/logout"
-# Load logout file usable by all shells.
-source_config ~/.shell "" logout
+source_config ~/.shell/logout
source_debug ". ~/.bash/logout (done)"
# Is sourced by all interactive shells and other shells like scp or rcp.
-# Get the current hostname (first part before a dot).
-host=$(echo $(hostname) | sed -e 's/\..*$//')
-
-# Load environmental related settings used by all shells.
-if [[ -f ~/.shell/env ]]; then
- . ~/.shell/env
-# Fallback functions as ~/.shell/env couldn't be loaded.
-else
- function source_debug() {
- echo $@
- }
- function source_config() {
- echo "Couldn't load source_config(), can't source files." >&2
- }
-fi
+. ~/.shell/functions
source_debug ". ~/.bash/rc"
-# Load global env file for current hostname (first part before a dot) or
-# global env.local.
-source_config ~/.shell "" env $host
+source_config ~/.shell/env
# Check if this is an interactive shell. Abort if not to prevent problems with
# Use Vi(m) style in bash.
set -o vi
-# Load aliases and similar functions also used by other shells.
-if [[ -f ~/.shell/aliases ]]; then
- . ~/.shell/aliases
-fi
+source_config ~/.shell/aliases
-# Load rc file for current hostname (first part before a dot) or rc.local.
-source_config ~/.bash host rc $host
+source_config ~/.bash/rc.local
source_debug ". ~/.bash/rc (done)"
# Configuration file for environment related options for all shells.
-. ~/.shell/functions
-
source_debug ". ~/.shell/env"
+++ /dev/null
-# Configuration file for environment related options for all shells for my
-# local computer.
-
-
-# Display options, necessary for X11 window manager.
-DISPLAY=':0.0'
-export DISPLAY
-
-# Set HTTP proxy for privoxy/tor.
-http_proxy=http://127.0.0.1:8119/
-HTTP_PROXY=$http_proxy
-export http_proxy HTTP_PROXY
-
-# Necessary for xterm to find man pages through PATH.
-unset MANPATH
-
-# vim: ft=sh
fi
}
-# Sources a configuration file if it exists; loads a fallback .local file if
-# it doesn't. If the .local files doesn't exist nothing is sourced.
-#
-# $1: Path to directory where configuration files are located.
-# $2: Directory name in $1 where the non .local files are stored, can be
-# empty. If empty both configuration files (normal and .local) are stored
-# in $1.
-# $3: Base name of file in $2, for example "rc" or "env".
-# $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
-# Can be empty, then no extension is used.
-# $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
-# if "$1/$2/$3.$4" doesn't exist.
-#
-# Example with the following directory/file structure, $os is Darwin and
-# $hostname is marvin.
-#
-# ~/.zsh
-# ~/.zsh/env
-# ~/.zsh/env.local
-# ~/.zsh/rc
-# ~/.zsh/rc.local
-# ~/.zsh/host/rc.marvin
-# ~/.zsh/os/rc.Darwin
-#
-# To load additional rc files from within ~/.zsh/rc use the following:
-#
-# source_config ~/.zsh os rc $os # loads os/rc.Darwin
-# source_config ~/.zsh host rc $hostname # loads host/rc.marvin
-#
-# To load additional env files from within ~/.zsh/env use the following (note
-# nolocal to prevent loading env.local two times if os and host files don't
-# exist):
-#
-# source_config zsh os env $os nolocal # loads os/rc.Darwin
-# source_config zsh host env $hostname # loads env.local
-#
-# By letting $4 empty normal configuration files can be sourced. A .local can
-# still be used.
-#
-# source_config zsh "" file # loads zsh/file if it exists
-#
-# Doesn't fit perfectly in this file, but this is the best place to make it
-# available everywhere.
-#
-# If DEBUG is set to a non empty value additional debug output is printed.
+# Source $1 if it exists. And $1.local if it exists as well.
source_config() {
- # Path to the file to source and its local counterpart.
- if [ x$4 != x ]; then
- source_file=$1/$2/$3.$4
- # If $4 is empty don't append a trailing dot. This allows source_config()
- # to load normal configuration files.
- else
- source_file=$1/$2/$3
- fi
- source_file_local=$1/$3.local
-
- # Additional debug output.
- source_debug "source_config(): checking if $source_file exists"
- source_debug "source_config(): checking if $source_file_local exists"
+ source_debug "source_config(): $1"
- # If the file does exist then source it.
- if [ -f $source_file ]; then
- source_debug "source_config(): -> sourcing $source_file"
- . $source_file
-
- # Otherwise load the .local file if it exists and .local files are
- # allowed.
- elif [ -f $source_file_local -a x$5 != xnolocal ]; then
- source_debug "source_config(): -> sourcing $source_file_local"
- . $source_file_local
- else
- source_debug "source_config(): -> neither exists"
+ if [ -f $1 ]; then
+ source_debug "source_config(): . $1"
+ . $1
fi
- unset source_file source_file_local
+ if [ -f $1.local ]; then
+ source_debug "source_config(): . $1.local"
+ . $1.local
+ fi
}
# vim: ft=sh
+++ /dev/null
-# Runs all tests.
-
-
-# Get all test files.
-for file in *.test; do
- # Run the test file in zsh and sh and get its output.
- zsh $file &> $file.out.zsh
- sh $file &> $file.out.sh
-
- # Check if the output matches the expected one. If not abort with exit
- # code 1.
- diff -u $file.out $file.out.zsh
- if [[ $? -ne 0 ]]; then
- exit 1
- fi
- diff -u $file.out $file.out.sh
- if [[ $? -ne 0 ]]; then
- exit 1
- fi
-done
-
-# Remove all temporary files.
-rm -rf tmp
-rm *.out.zsh
-rm *.out.sh
+++ /dev/null
-# Test file for source_config().
-
-
-# Load source_config().
-. ../shell/env
-
-
-# Make sure the old temporary directory is removed.
-rm -rf tmp
-# Create the test directories/files.
-mkdir tmp
-mkdir tmp/bash
-mkdir tmp/shell
-mkdir tmp/zsh tmp/zsh/host tmp/zsh/os
-echo echo loaded bash/env.zucker > tmp/shell/env.zucker
-echo echo loaded shell/env.zucker > tmp/shell/env.zucker
-echo echo loaded shell/logout > tmp/shell/logout
-echo echo loaded zsh.env.local > tmp/zsh/env.local
-echo echo loaded zsh/rc.local > tmp/zsh/rc.local
-echo echo loaded zsh/host/rc.zucker > tmp/zsh/host/rc.zucker
-echo echo loaded zsh/os/rc.Darwin > tmp/zsh/os/rc.Darwin
-
-
-function tests() {
- source_config tmp/zsh os rc Darwin nolocal
- echo -n $source_file$source_file_local
- source_config tmp/zsh host rc zucker
- echo -n $source_file$source_file_local
-
- source_config tmp/zsh os env Darwin nolocal
- echo -n $source_file$source_file_local
- source_config tmp/zsh host env zucker
- echo -n $source_file$source_file_local
-
- source_config tmp/bash host rc zucker
- echo -n $source_file$source_file_local
-
- source_config tmp/shell "" env zucker
- echo -n $source_file$source_file_local
-
- source_config tmp/shell "" logout
- echo -n $source_file$source_file_local
- source_config tmp/shell "" doesnt-exist
- echo -n $source_file$source_file_local
-}
-
-# Run tests without and with debug output.
-tests
-echo
-DEBUG=1 tests
-
-# vim: ft=sh
+++ /dev/null
-loaded zsh/os/rc.Darwin
-loaded zsh/host/rc.zucker
-loaded zsh.env.local
-loaded shell/env.zucker
-loaded shell/logout
-
-source_config(): checking if tmp/zsh/os/rc.Darwin exists
-source_config(): checking if tmp/zsh/rc.local exists
-source_config(): -> sourcing tmp/zsh/os/rc.Darwin
-loaded zsh/os/rc.Darwin
-source_config(): checking if tmp/zsh/host/rc.zucker exists
-source_config(): checking if tmp/zsh/rc.local exists
-source_config(): -> sourcing tmp/zsh/host/rc.zucker
-loaded zsh/host/rc.zucker
-source_config(): checking if tmp/zsh/os/env.Darwin exists
-source_config(): checking if tmp/zsh/env.local exists
-source_config(): -> neither exists
-source_config(): checking if tmp/zsh/host/env.zucker exists
-source_config(): checking if tmp/zsh/env.local exists
-source_config(): -> sourcing tmp/zsh/env.local
-loaded zsh.env.local
-source_config(): checking if tmp/bash/host/rc.zucker exists
-source_config(): checking if tmp/bash/rc.local exists
-source_config(): -> neither exists
-source_config(): checking if tmp/shell//env.zucker exists
-source_config(): checking if tmp/shell/env.local exists
-source_config(): -> sourcing tmp/shell//env.zucker
-loaded shell/env.zucker
-source_config(): checking if tmp/shell//logout exists
-source_config(): checking if tmp/shell/logout.local exists
-source_config(): -> sourcing tmp/shell//logout
-loaded shell/logout
-source_config(): checking if tmp/shell//doesnt-exist exists
-source_config(): checking if tmp/shell/doesnt-exist.local exists
-source_config(): -> neither exists
# Zsh configuration file for environment related options.
-# Get the current hostname (first part before a dot).
-host=${$(hostname)//.*/}
-
-# Load environmental related settings used by all shells.
-if [[ -f ~/.shell/env ]]; then
- . ~/.shell/env
-# Fallback functions as ~/.shell/env couldn't be loaded.
-else
- function source_debug() {
- echo $@
- }
- function source_config() {
- echo "Couldn't load source_config(), can't source files." >&2
- }
-fi
+. ~/.shell/functions
source_debug ". ~/.zsh/env"
+source_config ~/.shell/env
+
# Make sure elements in PATH are unique.
typeset -U path PATH
-# Load global env file for current hostname (first part before a dot) or
-# global env.local.
-source_config ~/.shell "" env $host
-
-# Load env file for current hostname (first part before a dot) or env.local.
-source_config ~/.zsh host env $host
+source_config ~/.zsh/env.local
source_debug ". ~/.zsh/env (done)"
+++ /dev/null
-# Zsh configuration file for environment related options for my father's G5.
-
-
-# Update the default PATH to include MacPorts, X11, and /usr/local.
-typeset -U path
-path=(/opt/local/bin /opt/local/sbin /usr/local/bin $path /usr/X11R6/bin)
-
-# vim: ft=zsh
+++ /dev/null
-# Zsh configuration file for environment related options for my local computer.
-
-
-# Path to my local "unix" directory where my scripts, configuration files and
-# other unix related data is stored.
-MYUNIX=~/Documents/unix
-
-# Add my bin/ directory, macports bin/ and sbin/ and the X11 bin/ directory to
-# the default PATH. -g is necessary as the file is loaded by source_config(),
-# otherwise the path wouldn't be changed outside the function.
-typeset -g -U path
-path=($MYUNIX/bin /opt/local/bin /opt/local/sbin $path /usr/X11R6/bin)
-
-# vim: ft=zsh
+++ /dev/null
-# Zsh configuration file for my local computer.
-
-
-# Shortcuts for the prompt and to cd to important directories.
-unix=~/Documents/unix
-macports=${unix}/macports
-htdocs=/Library/WebServer/Documents
-page=${htdocs}/page
-# Activate these shortcuts.
-: ~unix ~macports ~htdocs ~page
-
-# Aliases for easy and fast cd to important directories.
-alias cdu='cd ~unix'
-alias cdm='cd ~macports'
-alias cdh='cd ~htdocs'
-alias cdp='cd ~page'
-
-# Path to my mail spoolfile.
-MAIL=/var/mail/$USER
-# Check for new mails every ten seconds.
-MAILCHECK=10
-
-# vim: ft=zsh
+++ /dev/null
-# Zsh configuration file for zucker.schokokeks.org.
-
-
-# Shortcuts for the prompt and to cd to important directories.
-htdocs=~/websites/ruderich.org/htdocs
-logs=/var/log/apache2/ruderich
-# Activate these shortcuts.
-: ~htdocs ~logs
-
-# Aliases for easy and fast cd to important directories.
-alias cdh='cd ~htdocs'
-alias cdl='cd ~logs'
-
-# vim: ft=zsh
source_debug ". ~/.zsh/logout"
-# Load logout file usable by all shells.
-source_config ~/.shell "" logout
+source_config ~/.shell/logout
source_debug ". ~/.zsh/logout (done)"
# LOAD ADDITIONAL CONFIGURATION FILES
-# Load rc file for current hostname (first part before a dot) or rc.local.
-source_config ~/.zsh host rc ${$(hostname)//.*/}
+source_config ~/.zsh.rc.local
# RUN COMMANDS