--- /dev/null
+Alexander Barton <alex@barton.de>
--- /dev/null
+The MIT License
+
+- Copyright (c) 2015 Alexander Barton <alex@barton.de>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
--- /dev/null
+AX-ZSH: Alex' Modular ZSH Configuration
+=======================================
+
+
+Environment Variables
+---------------------
+
+Expected to be already set:
+
+* `HOME`
+* `LOGNAME`
+
+Validated and/or set up:
+
+* `AXZSH`
+* `HOST`
+* `HOSTNAME` (same as HOST, deprecated)
+* `LOCAL_HOME`
+* `PS1`
+* `SHORT_HOST`
+* `TERM`
+* `XDG_CACHE_HOME`
+* `ZSH_CACHE_DIR`
+
+
+Configuration Variables
+-----------------------
+
+The following configuration variables can be set in the `$HOME/.zshenv` file
+to configure "AX-ZSH":
+
+* `AXZSH_PLUGIN_D`
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# Copyright (c) 2015 Alexander Barton <alex@barton.de>
+
+# Load plugin code of a given type.
+# - $1: plugin name
+# - $2: plugin type (optional; defaults to "zshrc")
+function axzsh_load_plugin {
+ plugin="$1"
+ [[ -z "$2" ]] && type="zshrc" || type="$2"
+
+ for dname in \
+ "$AXZSH_PLUGIN_D/$plugin" \
+ "$AXZSH/plugins/$plugin" \
+ "$AXZSH/core/$plugin" \
+ ; do
+ [[ ! -d "$dname" ]] && continue
+
+ fname="$dname/$plugin.$type"
+ if [[ ! -r "$fname" && "$type" == "zshrc" ]]; then
+ if [[ -r "$dname/$plugin.plugin.zsh" ]]; then
+ # Oh My ZSH plugin
+ type="plugin.zsh"
+ fname="$dname/$plugin.plugin.zsh"
+ elif [[ -r "$dname/init.zsh" ]]; then
+ # Prezto module
+ type="init.zsh"
+ fname="$dname/init.zsh"
+ fi
+ fi
+
+ if [[ -r "$fname" ]]; then
+ [[ -f "$HOME/.axzsh.debug" ]] \
+ && echo " - $plugin ($type) ..."
+ source "$fname"
+ return 0
+ fi
+ return 0
+ done
+ [[ -f "$HOME/.axzsh.debug" ]] \
+ && echo "Plugin \"$plugin\" not found (type \"$type\")!" >/dev/stderr
+ return 1
+}
+
+# Make sure that "AXZSH" variable is set and exported
+if [[ -z "$AXZSH" ]]; then
+ export AXZSH="$HOME/.axzsh"
+ [[ -f "$HOME/.axzsh.debug" ]] && echo "AXZSH=$AXZSH"
+fi
+
+# Setup list of default plugins if not set already. This allows users to
+# overwrite this list in their "~/.zshrnv" file, for example.
+typeset -U axzsh_default_plugins
+if ! typeset +m axzsh_default_plugins | fgrep array >/dev/null 2>&1; then
+ axzsh_default_plugins=(
+ byebye
+ completion
+ correction
+ git
+ history
+ homebrew
+ ls
+ prompt
+ ssh
+ std_aliases
+ )
+fi
+
+# Setup list of plugins to load:
+typeset -U plugin_list
+plugin_list=(
+ $AXZSH/core/[0-5]*
+ $axzsh_default_plugins
+ $axzsh_plugins
+ $plugins
+ $AXZSH/core/[6-9]*
+)
+
+# Read in all the plugins for the current "type":
+script_name="$(basename -- "${(%):-%N}")"
+script_type="$script_name[2,-1]"
+[[ -f "$HOME/.axzsh.debug" ]] && echo "» $script_name:"
+for plugin ($plugin_list); do
+ axzsh_load_plugin "$(basename "$plugin")" "$script_type"
+done
+unset script_name script_type plugin
+unset plugin_list
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 10_terminal.zprofile: Initialize terminal settings
+
+[[ -t 0 ]] && eval `tset -s`
+[[ -z "$TERM" ]] && TERM="dumb"
+export TERM
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 10_terminal.zshrc: Initialize terminal settings
+
+# Set terminal title
+
+function axzsh_terminal_precmd {
+ printf '\e]1;%s\a' "$LOGNAME@$SHORT_HOST"
+}
+
+precmd_functions+=(axzsh_terminal_precmd)
+
+# Set current working directory
+
+function axzsh_terminal_cwd {
+ if [[ $TERM_PROGRAM == Apple_Terminal ]]; then
+ local url="file://$HOSTNAME${PWD// /%20}"
+ printf '\e]7;%s\a' "$url"
+ fi
+}
+
+precmd_functions+=(axzsh_terminal_cwd)
+
+# Colors
+
+autoload -U colors
+colors
+
+# Text effects (FX)
+
+typeset -Ag fx
+fx=(
+ reset "\e[00m"
+ bold "\e[01m"
+ no-bold "\e[22m"
+ italic "\e[03m"
+ no-italic "\e[23m"
+ underline "\e[04m"
+ no-underline "\e[24m"
+ blink "\e[05m"
+ no-blink "\e[25m"
+ reverse "\e[07m"
+ no-reverse "\e[27m"
+)
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 20_home.zprofile: Setup (local) home directory
+
+[[ -d "/usr/local/home" && ! -d "/usr/local/home/$LOGNAME" ]] \
+ && mkdir "/usr/local/home/$LOGNAME" >/dev/null 2>&1
+
+[[ -w "/usr/local/home/$LOGNAME" ]] \
+ && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
+ || export LOCAL_HOME="$HOME"
+
+# Setup XDG cache directory
+export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
+mkdir -p "$XDG_CACHE_HOME"
+
+# Setup ZSH cache directory
+export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
+mkdir -p "$ZSH_CACHE_DIR"
+
+# Update PATH to include directories inside of the $HOME directory
+typeset -U path
+for dir in ~/bin ~/sbin ~/Applications; do
+ [[ -d "$dir" ]] && path[1,0]="$dir"
+done
+unset dir
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 30_hostname.zprofile: Initialize hostname settings
+
+# Setup "HOSTNAME" variable
+[[ -z "$HOSTNAME" ]] && HOSTNAME=$( hostname )
+export HOSTNAME
+
+# Setup "SHORT_HOST" variable
+[[ "$OSTYPE" = darwin* ]] \
+ && SHORT_HOST=$(scutil --get ComputerName 2>/dev/null)
+[[ -z "$SHORT_HOST" ]] && SHORT_HOST=${HOST/.*/}
+export SHORT_HOST
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 50_prompt.zshrc: Setup default prompts
+
+# Logname ("user name")
+
+(( $UID == 0 )) \
+ && ZSH_THEME_LOGNAME_PROMPT_PREFIX="%{$fg_no_bold[red]%}" \
+ || ZSH_THEME_LOGNAME_PROMPT_PREFIX=""
+ZSH_THEME_LOGNAME_PROMPT_SUFFIX="%{$reset_color%}@"
+
+function ax_logname_prompt_root() {
+ (( $UID == 0 )) || return 1
+ echo "$LOGNAME"
+ return 0
+}
+
+ax_logname_prompt_functions=($ax_logname_prompt_functions ax_logname_prompt_root)
+
+function ax_logname_prompt() {
+ local func
+ local p
+ for func ($ax_logname_prompt_functions); do
+ p=$( $func ) || continue
+ echo "${ZSH_THEME_LOGNAME_PROMPT_PREFIX}${p}${ZSH_THEME_LOGNAME_PROMPT_SUFFIX}"
+ return
+ done
+}
+
+# Hostname
+
+ZSH_THEME_HOSTNAME_PROMPT_PREFIX=""
+ZSH_THEME_HOSTNAME_PROMPT_SUFFIX="%{$reset_color%}:"
+
+function ax_hostname_prompt_root() {
+ (( $UID == 0 )) || return 1
+ echo "$SHORT_HOST"
+ return 0
+}
+
+ax_hostname_prompt_functions=($ax_hostname_prompt_functions ax_hostname_prompt_root)
+
+function ax_hostname_prompt() {
+ local func
+ local p
+ for func ($ax_hostname_prompt_functions); do
+ p=$( $func ) || continue
+ echo "${ZSH_THEME_HOSTNAME_PROMPT_PREFIX}${p}${ZSH_THEME_HOSTNAME_PROMPT_SUFFIX}"
+ return
+ done
+}
+
+# VCS
+
+ZSH_THEME_VCS_PROMPT_PREFIX="(%{$fg_no_bold[yellow]%}"
+ZSH_THEME_VCS_PROMPT_SUFFIX="%{$reset_color%}) "
+
+ZSH_THEME_VCS_PROMPT_CLEAN="%{$fg_no_bold[green]%}✔"
+ZSH_THEME_VCS_PROMPT_DIRTY="%{$fg_no_bold[red]%}✘"
+ZSH_THEME_VCS_PROMPT_AHEAD="%{$fg_no_bold[cyan]%}→"
+ZSH_THEME_VCS_PROMPT_BEHIND="%{$fg_no_bold[blue]%}←"
+
+function ax_vcs_prompt() {
+ local func
+ local p
+ for func ($ax_vcs_prompt_functions); do
+ p=$( $func ) || continue
+ echo "${ZSH_THEME_VCS_PROMPT_PREFIX}${p}${ZSH_THEME_VCS_PROMPT_SUFFIX}"
+ return
+ done
+}
+
+# Options and defaults
+
+setopt PROMPT_SUBST
+
+export PS1 RPS1
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 80_local_config.zlogin: Read local configuration
+
+[[ -r "/var/lib/$HOST/zlogin" ]] \
+ && source "/var/lib/$HOST/zlogin"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 80_local_config.zlogout: Read local configuration
+
+[[ -r "/var/lib/$HOST/zlogout" ]] \
+ && source "/var/lib/$HOST/zlogout"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 80_local_config.zprofile: Read local configuration
+
+[[ -r "/var/lib/$HOST/zprofile" ]] \
+ && source "/var/lib/$HOST/zprofile"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 80_local_config.zshrc: Read local configuration
+
+[[ -r "/var/lib/$HOST/zshrc" ]] \
+ && source "/var/lib/$HOST/zshrc"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# completion.zshrc: Setup completion
+
+# Make sure that "compinit" is available
+type compinit >/dev/null || return
+
+# Save the location of the current completion dump file.
+if [[ -z "$ZSH_COMPDUMP" ]]; then
+ ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
+fi
+
+# Initialize ZSH completion system
+compinit -d "$ZSH_COMPDUMP"
--- /dev/null
+#!/bin/sh
+#
+# AX-ZSH: Alex' Modular ZSH Configuration
+# Copyright (c) 2015 Alexander Barton <alex@barton.de>
+#
+
+safe_rm() {
+ if [ -f "$1" -a ! -L "$1" ]; then
+ rm -f "$1.bak" || exit 1
+ mv -v "$1" "$1.bak" || exit 1
+ fi
+ rm -f "$1" || exit 1
+}
+
+for f in ~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc; do
+ safe_rm "$f" || exit 1
+ ln -sv "$PWD/ax.zsh" "$f" || exit 1
+done
+
+safe_rm ~/.axzsh || exit 1
+ln -sv "$PWD" ~/.axzsh || exit 1
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# byebye.zlogout -- Say goodbye to interactive users
+
+[[ -o interactive ]] \
+ && echo "Bye, bye, $LOGNAME!"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# completion.zshrc: Setup completion
+
+autoload -U compinit
+
+setopt completealiases
+
+zstyle ':completion:*' list-colors ''
+zstyle ':completion:*' menu select
+zstyle ':completion:*' special-dirs true
+
+# Use caching so that commands like apt and dpkg completions are useable
+zstyle ':completion::complete:*' use-cache 1
+zstyle ':completion::complete:*' cache-path "$ZSH_CACHE_DIR"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# correction.zshrc: Setup correction
+
+for cmd in \
+ brew \
+ ebuild \
+ gist \
+ man \
+ mkdir \
+ mv \
+ mysql \
+ sudo \
+; do
+ [[ -n $commands[$cmd] ]] \
+ && alias $cmd="nocorrect $cmd"
+done
+
+setopt correct_all
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# git.zshrc: Setup Git
+
+# Make sure that "git(1)" is installed
+(( $+commands[git] )) || return
+
+git_parse_dirty() {
+ local flags
+ flags=(
+ '--porcelain'
+ '--ignore-submodules=dirty'
+ #'--untracked-files=no'
+ )
+ [[ -n "$(git status $flags 2>/dev/null | tail -n1)" ]] \
+ && echo "$ZSH_THEME_VCS_PROMPT_DIRTY" \
+ || echo "$ZSH_THEME_VCS_PROMPT_CLEAN"
+}
+
+git_current_branch() {
+ local ref=$(git symbolic-ref --quiet HEAD 2>/dev/null)
+ local ret=$?
+ if [[ $ret != 0 ]]; then
+ [[ $ret == 128 ]] && return # No Git repository
+ ref=$(git rev-parse --short HEAD 2>/dev/null) || return
+ fi
+ echo "${ref#refs/heads/}"
+}
+
+git_prompt_ahead() {
+ [[ -n "$(git rev-list "@{upstream}..HEAD" 2>/dev/null)" ]] \
+ && echo "$ZSH_THEME_VCS_PROMPT_AHEAD"
+}
+
+git_prompt_behind() {
+ [[ -n "$(git rev-list HEAD..@{upstream} 2>/dev/null)" ]] \
+ && echo "$ZSH_THEME_VCS_PROMPT_BEHIND"
+}
+
+git_prompt() {
+ ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1
+ echo "${ref#refs/heads/} $(git_parse_dirty)$(git_prompt_ahead)$(git_prompt_behind)"
+ return 0
+}
+
+ax_vcs_prompt_functions=($ax_vcs_prompt_functions git_prompt)
+
+alias "ga"="git add"
+alias "gc"="git commit"
+alias "gd"="git diff"
+alias "gdc"="git diff --cached"
+alias "gst"="git status --short --branch --untracked"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# history.zshrc: Setup ZSH history
+
+[[ -z "$HISTFILE" ]] && HISTFILE="$HOME/.zsh_history"
+
+HISTSIZE=10000
+SAVEHIST=10000
+
+setopt append_history
+setopt extended_history
+setopt hist_expire_dups_first
+setopt hist_ignore_dups
+setopt hist_ignore_space
+setopt hist_verify
+setopt inc_append_history
+setopt share_history
+
+alias history='fc -il 1'
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# homebrew.zshrc -- Setup Homebrew Package Manager
+
+# Make sure that "brew(1)" is installed
+(( $+commands[brew] )) || return
+
+[[ -d "/usr/local/share/zsh-completions" ]] \
+ && fpath=(/usr/local/share/zsh-completions $fpath)
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# ls.zshrc: Setup ls(1)
+
+# Check which ls-alike command to use
+if (( $+commands[gls] )); then
+ cmd="gls" # GNU ls (on NetBSD, for example)
+elif (( $+commands[colorls] )); then
+ cmd="colorls" # OpenBSD
+else
+ cmd="ls"
+fi
+
+if $cmd --color -d . >/dev/null 2>&1; then
+ alias ls="$cmd -F --color=tty"
+ return 0
+fi
+if $cmd -G -d . >/dev/null 2>&1; then
+ alias ls="$cmd -FG"
+ return 0
+fi
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# prompt.zlogin: Setup default prompts
+
+# Default prompt
+PS1='$(ax_logname_prompt)$(ax_hostname_prompt)%B%2~%b $(ax_vcs_prompt)%{$fg_no_bold[green]%}%B$%b%{$reset_color%} '
+
+# Prompt on right side
+RPS1="%(?..%{$fg_no_bold[red]%}%? ↵%{$reset_color%})"
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# ssh.zshrc: Setup (Open-) SSH
+
+ssh_logname_prompt() {
+ [[ -n "$SSH_CLIENT" ]] || return 1
+ echo "$LOGNAME"
+ return 0
+}
+
+ax_logname_prompt_functions=($ax_logname_prompt_functions ssh_logname_prompt)
+
+ssh_hostname_prompt() {
+ [[ -n "$SSH_CLIENT" ]] || return 1
+ echo "$SHORT_HOST"
+ return 0
+}
+
+ax_hostname_prompt_functions=($ax_hostname_prompt_functions ssh_hostname_prompt)
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# std_aliases: Setup standard aliases
+
+alias ".."="cd .."
+
+alias "ll"="ls -hl"
+alias "l"="ll -a"