diff --git a/rc b/rc deleted file mode 100644 index 4c9e117..0000000 --- a/rc +++ /dev/null @@ -1,120 +0,0 @@ -# .rc -# vim: ft=zsh -# Generic interactive shell setup -# Eryn Wells - -print_heading -l 1 'Initializing interactive shell' - -print_info -l 2 'Creating aliases' -alias j='jobs' -alias h='history' -alias df='df -h' -alias du='du -h' -alias e='emacs' - -binary_exists ledger && alias l='ledger' -binary_exists gpg2 && alias gpg='gpg2' -binary_exists keybase && alias keybase="keybase --gpg \"`which gpg2`\"" - -alias chux='chmod u+x' -alias chuw='chmod u+w' -alias chur='chmod u+r' -alias cho="chown $USER" - -alias today='date +%Y-%m-%d' - -alias addkey="ssh-agent ~/.ssh/id_rsa" - -alias pprint="python -c 'import sys,pprint; pprint.pprint(eval(sys.stdin.read()))'" -alias pprint-json="python -c 'import sys,json;print json.dumps(json.load(sys.stdin), indent=2)'" - -# -# Git -# - -function g -{ - if [[ $# -gt 0 ]]; then - git $@ - else - git status --short --branch - fi - return $? -} - -function vi -{ - if whence -cp nvim 1>/dev/null 2>&1; then - command nvim $@ - elif whence -cp vim 1>/dev/null 2>&1; then - command vim $@ - elif whence -cp vi 1>/dev/null 2>&1; then - command vi $@ - fi -} - -alias gp='g p origin $gitbranch' -alias gpf='g p -f origin $gitbranch' - -# -# Setup -# - -function configure_ls -{ - local has_gnu_ls - local ls_options - - if [[ ! -e "$1" ]]; then - return - fi - - if $1 --version 2>&1 | grep GNU 1>/dev/null; then - has_gnu_ls=1 - ls_options='--color=auto' - else - has_gnu_ls=0 - ls_options='-G' - fi - - print_info_sub -l 3 "Setting up ls: $1" - alias ls="$1 $ls_options" - alias la="$1 -A $ls_options" - alias ll="$1 -l $ls_options" - alias l.="$1 -d $ls_options .*" - - local dircolors_bin=`whence -p dircolors || whence -p gdircolors` - if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then - if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then - dircolors="$HOME/.dircolors/$SYS.cfg" - else - dircolors="$HOME/.dircolors/default.cfg" - fi - print_info_sub -l 3 "Setting up dircolors: `basename $dircolors`" - eval `$dircolors_bin $dircolors` - fi -} - - -# NetHack options -# use color in the terminal -binary_exists nethack && export NETHACKOPTIONS="color" - -# Default ledger file -[[ -e "$HOME/Documents/Ledger/personal.ledger" ]] && \ - LEDGER_FILE=$HOME/Documents/Ledger/personal.ledger - -if [[ -e "$HOME/.rc.$SYS" ]]; then - print_info -l 2 "Sourcing $SYS interactive shell setup" - source "$HOME/.rc.$SYS" -fi - -# Set up ls if it wasn't already done. -if ! alias ls 2>&1 1>/dev/null; then - configure_ls `which ls` -fi - -if [[ -e "$HOME/.rc.local" ]]; then - print_info -l 2 'Sourcing local interactive shell setup' - source "$HOME/.rc.local" -fi diff --git a/rc.darwin b/rc.darwin deleted file mode 100644 index 7a82919..0000000 --- a/rc.darwin +++ /dev/null @@ -1,52 +0,0 @@ -# .rc.darwin -# vim: ft=zsh -# Interactive shell setup for Darwin systems -# Eryn Wells - -alias acls='command ls -le' - -# These things might have been installed by Homebrew, and I like the GNU versions better. -binary_exists gdircolors && alias dircolors='gdircolors' -binary_exists gfind && alias find='gfind' -binary_exists gnuindent && alias indent='gnuindent' - -if binary_exists gls; then - configure_ls `which gls` -fi - -# ldd doesn't exist on OS X, but otool -L does the same thing. -alias ldd='otool -L' - -SOUNDSDIR=/System/Library/Sounds -alias glass="afplay $SOUNDSDIR/Glass.aiff" -alias funk="afplay $SOUNDSDIR/Funk.aiff" -unset SOUNDSDIR - -function darwin-icloud-drive-path -{ - echo "$HOME/Library/Mobile Documents/com~apple~CloudDocs" -} - -function darwin-init -{ - # Dim dock icons of apps that have been hidden. - print_info "Auto-hiding Dock" - defaults write com.apple.Dock showhidden -boolean yes - killall Dock - - # Put screenshots in iCloud Drive, in a directory according to hostname - icloud=`darwin-icloud-drive-path` - if [[ -d "$icloud" ]]; then - local name=`hostname -s | tr A-Z a-z` - local loc="$(darwin-icloud-drive-path)/Screenshots/$name" - print_info "Setting screenshot directory: $loc" - mkdir -p "$loc" - defaults write com.apple.screencapture location "$loc" - else - echo "iCloud directory doesn't exist: $icloud" - fi - - echo "Disabling overly restrictive Gatekeeper" - # See https://techstuffer.com/this-app-is-damaged-error-macos-sierra/ - sudo spctl --master-disable -} diff --git a/rc.freebsd b/rc.freebsd deleted file mode 100644 index b38cceb..0000000 --- a/rc.freebsd +++ /dev/null @@ -1,4 +0,0 @@ -# .rc.freebsd -# vim: ft=zsh -# Interactive shell setup for FreeBSD systems -# Eryn Wells diff --git a/rc.linux b/rc.linux deleted file mode 100644 index baaa85f..0000000 --- a/rc.linux +++ /dev/null @@ -1,10 +0,0 @@ -# .rc.linux -# vim: ft=zsh -# Interactive shell setup for Linux systems -# Eryn Wells - - -# iptables aliases -alias iptls='sudo iptables --line-numbers -nv -L' -alias ip6tls='sudo ip6tables --line-numbers -nv -L' -alias rlx="xrdb $HOME/.Xdefaults" diff --git a/rc.local b/rc.local deleted file mode 100644 index 148c0ed..0000000 --- a/rc.local +++ /dev/null @@ -1,6 +0,0 @@ -# .rc.local -# vim: set ft=zsh: -# Local customizations for interactive shells -# Eryn Wells - - diff --git a/zsh/func/binary_exists b/zsh/func/binary_exists new file mode 100644 index 0000000..f11d16e --- /dev/null +++ b/zsh/func/binary_exists @@ -0,0 +1,10 @@ +# .zshrc +# vim:ft=zsh: +# Eryn Wells + +function binary_exists +{ + return $(hash $1 1>/dev/null 2>&1) +} + +binary_exists "$@" diff --git a/zsh/func/darwin_configure_screenshots_directory b/zsh/func/darwin_configure_screenshots_directory new file mode 100644 index 0000000..cee8b09 --- /dev/null +++ b/zsh/func/darwin_configure_screenshots_directory @@ -0,0 +1,24 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload darwin_icloud_drive_path + +function darwin_configure_screenshots_directory +{ + icloud=`darwin_icloud_drive_path` + if [[ ! -d "$icloud" ]]; then + shell-log -l error "iCloud directory doesn't exist: $icloud" + return 1 + fi + + # Put screenshots in iCloud Drive, in a directory according to hostname + local name=`hostname -s | tr A-Z a-z` + local screenshots_dir="$icloud/Screenshots/$name" + shell-log "Setting screenshot directory: $screenshots_dir" + mkdir -p "$screenshots_dir" + defaults write com.apple.screencapture screenshots_diration "$screenshots_dir" + + return 0 +} + +darwin_configure_screenshots_directory "$@" diff --git a/zsh/func/darwin_icloud_drive_path b/zsh/func/darwin_icloud_drive_path new file mode 100644 index 0000000..d351001 --- /dev/null +++ b/zsh/func/darwin_icloud_drive_path @@ -0,0 +1,9 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function darwin_icloud_drive_path +{ + echo "$HOME/Library/Mobile Documents/com~apple~CloudDocs" +} + +darwin_icloud_drive_path "$@" diff --git a/zsh/func/darwin_init_once b/zsh/func/darwin_init_once new file mode 100644 index 0000000..c0259ed --- /dev/null +++ b/zsh/func/darwin_init_once @@ -0,0 +1,21 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload darwin_icloud_drive_path +autoload darwin_configure_screenshots_directory + +function darwin_init_once +{ + # Dim dock icons of apps that have been hidden. + shell-log "Auto-hiding Dock" + defaults write com.apple.Dock showhidden -boolean yes + killall Dock + + darwin_configure_screenshots_directory + + # See https://techstuffer.com/this-app-is-damaged-error-macos-sierra/ + shell-log "Disabling overly restrictive Gatekeeper" + sudo spctl --master-disable +} + +darwin_init_once "$@" diff --git a/zsh/func/g b/zsh/func/g new file mode 100644 index 0000000..75cd46a --- /dev/null +++ b/zsh/func/g @@ -0,0 +1,14 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function g +{ + if [[ $# -gt 0 ]]; then + git $@ + else + git status --short --branch + fi + return $? +} + +g "$@" diff --git a/zsh/func/init_app_environments b/zsh/func/init_app_environments new file mode 100644 index 0000000..dbd7a51 --- /dev/null +++ b/zsh/func/init_app_environments @@ -0,0 +1,17 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload binary_exists + +function init_app_environments +{ + # NetHack options + # use color in the terminal + binary_exists nethack && export NETHACKOPTIONS="color" + + # Default ledger file + local ledgerFile="$HOME/Documents/Ledger/personal.ledger" + [[ -e "$ledgerFile" ]] && LEDGER_FILE="$ledgerFile" +} + +init_app_environments "$@" diff --git a/zsh/func/init_rc_aliases b/zsh/func/init_rc_aliases new file mode 100644 index 0000000..cbbe945 --- /dev/null +++ b/zsh/func/init_rc_aliases @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload binary_exists + +function init_rc_aliases +{ + shell-log -l 'debug' "Setting up shell aliases" + + alias j='jobs' + alias h='history' + alias df='df -h' + alias du='du -h' + alias e='emacs' + + alias chux='chmod u+x' + alias chuw='chmod u+w' + alias chur='chmod u+r' + alias cho="chown $USER" + + alias today='date +%Y-%m-%d' + alias addkey="ssh-agent ~/.ssh/id_rsa" + + alias pprint="python -c 'import sys,pprint; pprint.pprint(eval(sys.stdin.read()))'" + alias pprint-json="python -c 'import sys,json;print json.dumps(json.load(sys.stdin), indent=2)'" + + alias gp='g p origin $gitbranch' + alias gpf='g p -f origin $gitbranch' + alias bx='bundle exec' + + binary_exists ledger && alias l='ledger' + binary_exists gpg2 && alias gpg='gpg2' + + shell-log -l debug 'Setting up suffix aliases' + alias -s c='vim' + alias -s tex='vim' + alias -s txt='vim' + alias -s xml='vim' + alias -s jar='java -jar' + +} + +init_rc_aliases "$@" diff --git a/zsh/func/init_rc_configure_completion b/zsh/func/init_rc_configure_completion new file mode 100644 index 0000000..c38f6fb --- /dev/null +++ b/zsh/func/init_rc_configure_completion @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_rc_configure_completion +{ + shell-log 'Initializing completion system' + + autoload -U compinit + compinit + + # Cache completions + zstyle ':completion::complete:*' use-cache 1 + zstyle ':completion::complete:*' cache-path ~/.zsh/cache + + zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} + + # For rm, cp, and mv don't complete if file is on the line already + zstyle ':completion:*:rm:*' ignore-line yes + zstyle ':completion:*:cp:*' ignore-line yes + zstyle ':completion:*:mv:*' ignore-line yes + + # Remove trailing slashes in directory arguments + zstyle ':completion:*' squeeze-slashes true + + # Never select parent directory + zstyle ':completion:*:cd:*' ignore-parents parent pwd + + # Expand partial paths + zstyle ':completion:*' expand 'yes' + + # Show a pretty menu of killable processes + zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' + zstyle ':completion:*:*:kill:*' menu yes select + + # Complete man pages by section + zstyle ':completion:*:manuals' separate-sections true + zstyle ':completion:*:manuals.*' insert-sections true + + # Use git completion for the g function + compdef g='git' +} + +init_rc_configure_completion "$@" diff --git a/zsh/func/init_rc_configure_ls b/zsh/func/init_rc_configure_ls new file mode 100644 index 0000000..1d08c35 --- /dev/null +++ b/zsh/func/init_rc_configure_ls @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_configure_ls +{ + local has_gnu_ls + local ls_options + + if [[ ! -e "$1" ]]; then + shell-log -l error 'Missing required path to ls binary' + return + fi + + if $1 --version 2>&1 | grep GNU 1>/dev/null; then + has_gnu_ls=1 + ls_options='--color=auto' + else + has_gnu_ls=0 + ls_options='-G' + fi + + shell-log -l debug "Setting up aliases for $1" + alias ls="$1 $ls_options" + alias la="$1 -A $ls_options" + alias ll="$1 -l $ls_options" + alias l.="$1 -d $ls_options .*" + + local dircolors_bin=`whence -p dircolors || whence -p gdircolors` + if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then + if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then + dircolors="$HOME/.dircolors/$SYS.cfg" + else + dircolors="$HOME/.dircolors/default.cfg" + fi + + shell-log -l debug "Setting up dircolors: `basename $dircolors`" + eval `$dircolors_bin $dircolors` + fi +} + +init_configure_ls "$@" diff --git a/zsh/func/init_rc_configure_prompt b/zsh/func/init_rc_configure_prompt new file mode 100644 index 0000000..14c411c --- /dev/null +++ b/zsh/func/init_rc_configure_prompt @@ -0,0 +1,37 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_rc_configure_prompt +{ + local theme=$1 + if [[ -z "$1" ]]; then + theme=loquacious + fi + + shell-log -l debug 'Configuring vcs_info' + + autoload -U add-zsh-hook + autoload -Uz vcs_info + + zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:git:general:*' formats '%b' + + # Export the current Git branch before every prompt. + function export_gitbranch { + vcs_info general + if [[ "$gitbranches[1]" != "${vcs_info_msg_0_}" ]]; then + export gitbranches=(${vcs_info_msg_0_} $gitbranches[1,4]) + fi + export gitbranch=${vcs_info_msg_0_} + } + + add-zsh-hook precmd export_gitbranch + + shell-log "Configuring prompt with '$theme' theme" + autoload -U promptinit + promptinit + prompt $theme +} + +init_rc_configure_prompt "$@" diff --git a/zsh/func/init_rc_configure_zle b/zsh/func/init_rc_configure_zle new file mode 100644 index 0000000..e535898 --- /dev/null +++ b/zsh/func/init_rc_configure_zle @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_rc_configure_zle +{ + shell-log 'Configuring ZLE' + + local mode=$1 + if [[ -z "$mode" ]]; then + mode=emacs + fi + + function configure_zle_emacs { } + function configure_zle_vim { } + + shell-log -l debug "Using $mode command line editing mode" + if [[ $mode == 'vim' ]]; then + bindkey -v + configure_zle_vim + zle -A .backward-delete-char vi-backward-delete-char + elif [[ $mode == 'emacs' ]]; then + bindkey -e + configure_zle_emacs + fi +} + +init_rc_configure_zle "$@" diff --git a/zsh/func/init_rc_darwin b/zsh/func/init_rc_darwin new file mode 100644 index 0000000..bd29e3a --- /dev/null +++ b/zsh/func/init_rc_darwin @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload binary_exists + +function init_rc_darwin +{ + shell-log 'Initializing Interactive Environment for macOS' + + alias acls='command ls -le' + + # These things might have been installed by Homebrew, and I like the GNU + # versions better. + binary_exists gdircolors && alias dircolors='gdircolors' + binary_exists gfind && alias find='gfind' + binary_exists gnuindent && alias indent='gnuindent' + + binary_exists gls && init_rc_configure_ls `which gls` + + # ldd doesn't exist on OS X, but otool -L does the same thing. + alias ldd='otool -L' + + local sounds=/System/Library/Sounds + alias glass="afplay $sounds/Glass.aiff" + alias funk="afplay $sounds/Funk.aiff" + + autoload +X darwin_init_once + autoload +X darwin_icloud_drive_path + autoload +X darwin_configure_screenshots_directory + + # Open a file/folder in Finder + alias reveal='open -R' + + alias -s app='open' + alias -s xcodeproj='open -a Xcode' +} + +init_rc_darwin "$@" diff --git a/zsh/func/init_rc_linux b/zsh/func/init_rc_linux new file mode 100644 index 0000000..43d081d --- /dev/null +++ b/zsh/func/init_rc_linux @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_rc_linux +{ + shell-log 'Initializing Interactive Environment for Linux' + + alias iptls='sudo iptables --line-numbers -nv -L' + alias ip6tls='sudo ip6tables --line-numbers -nv -L' + alias rlx="xrdb $HOME/.Xdefaults" +} + +init_rc_linux "$@" diff --git a/zsh/func/init_zsh_functions b/zsh/func/init_zsh_functions new file mode 100644 index 0000000..60f90dc --- /dev/null +++ b/zsh/func/init_zsh_functions @@ -0,0 +1,25 @@ +#!/usr/bin/env zsh +# Eryn Wells + +autoload load_module + +function init_zsh_functions +{ + local myfpath="$HOME/.zsh/func" + + shell-log "Loading functions in $myfpath" + for func in $myfpath/*; do + [[ ! -e "$func" || -d "$func" ]] && continue + + local functionName=`basename $func` + [[ "$functionName" =~ "prompt_*" ]] && continue + [[ "$functionName" =~ "init_*" ]] && continue + + shell-log -l debug "Loading $functionName" + autoload +X $functionName + done + + load_module makers +} + +init_zsh_functions "$@" diff --git a/zsh/func/init_zsh_history b/zsh/func/init_zsh_history new file mode 100644 index 0000000..63d22f0 --- /dev/null +++ b/zsh/func/init_zsh_history @@ -0,0 +1,23 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_zsh_history +{ + shell-log 'Setting up history' + + setopt \ + APPEND_HISTORY \ + EXTENDED_HISTORY \ + INC_APPEND_HISTORY \ + HIST_FIND_NO_DUPS \ + HIST_IGNORE_SPACE \ + HIST_NO_STORE \ + HIST_IGNORE_DUPS \ + HIST_REDUCE_BLANKS + + HISTSIZE=1000000 + SAVEHIST=1000000 + HISTFILE="$HOME/.zhistory" +} + +init_zsh_history "$@" diff --git a/zsh/func/init_zsh_options b/zsh/func/init_zsh_options new file mode 100644 index 0000000..dfc8aaf --- /dev/null +++ b/zsh/func/init_zsh_options @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function init_zsh_options +{ + shell-log 'Setting shell options' + + # Report seconds since shell was invoked in milliseconds + typeset -F SECONDS + + # See zshoptions(1) + setopt EXTENDED_GLOB \ + MULTIOS \ + AUTO_REMOVE_SLASH \ + COMPLETE_IN_WORD +} + +init_zsh_options "$@" diff --git a/zsh/func/load_module b/zsh/func/load_module new file mode 100644 index 0000000..21e9bad --- /dev/null +++ b/zsh/func/load_module @@ -0,0 +1,31 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function load_module +{ + local mod=$1 + + local modpath + for p in $fpath; do + modpath=$p/$mod + [[ -d $modpath ]] && break + modpath='' + done + + if [[ -z "$modpath" ]]; then + shell-log -l error "Couldn't find path to module: $mod" + return 1 + fi + + fpath+=($modpath) + + shell-log "Loading module: $mod" + for func in `ls $modpath`; do + shell-log "Loading function: $func" + autoload $func + done + + return 0 +} + +load_module "$@" diff --git a/zsh/func/vi b/zsh/func/vi new file mode 100644 index 0000000..8b768a1 --- /dev/null +++ b/zsh/func/vi @@ -0,0 +1,15 @@ +#!/usr/bin/env zsh +# Eryn Wells + +function vi +{ + if whence -cp nvim 1>/dev/null 2>&1; then + command nvim $@ + elif whence -cp vim 1>/dev/null 2>&1; then + command vim $@ + elif whence -cp vi 1>/dev/null 2>&1; then + command vi $@ + fi +} + +vi "$@" diff --git a/zshrc b/zshrc index 59f0cca..6ba39c9 100644 --- a/zshrc +++ b/zshrc @@ -1,259 +1,34 @@ -# .zshrc -# vim:ft=zsh:fdm=marker:sw=4:sts=4: -# -# ZSH init for interactive shells -# +#!/usr/bin/env zsh # Eryn Wells -PROMPT_THEME='loquacious' -ZLE_MODE='emacs' - - -# load bash/zsh/ksh agnostic configurations -[[ -e $HOME/.rc ]] && source $HOME/.rc - -print_heading -l 1 "Initializing interactive Z Shell" - - -function configure_general #{{{ -{ - print_info -l 2 'Configuring general ZSH settings' - - # Report seconds since shell was invoked in milliseconds - typeset -F SECONDS - - print_info_sub -l 3 'Setting shell options' - # See zshoptions(1) - setopt EXTENDED_GLOB \ - MULTIOS \ - AUTO_REMOVE_SLASH \ - COMPLETE_IN_WORD -} #}}} - - -# Configure oh-my-zsh -function configure_omz #{{{ -{ - if [[ ! -d ~/.oh-my-zsh ]]; then - print_error -l 2 "No ~/.oh-my-zsh directory; skipping" - return - fi - - print_info -l 2 'Configuring Oh My ZSH!' - - ZSH=$HOME/.oh-my-zsh - DISABLE_AUTO_UPDATE="true" - COMPLETION_WAITING_DOTS="true" - - plugins=(autojump brew encode64 fasd gnu-utils history osx python) - - source $ZSH/oh-my-zsh.sh - - alias v='f -t -e vim -b viminfo' -} #}}} - - -function configure_zle #{{{ -{ - print_info -l 2 'Configuring ZLE' - - print_info_sub -l 5 "Using $ZLE_MODE command line editing mode" - [[ -z "$ZLE_MODE" ]] && ZLE_MODE='vim' - if [[ $ZLE_MODE == 'vim' ]]; then - bindkey -v - configure_zle_vim - elif [[ $ZLE_MODE == 'emacs' ]]; then - bindkey -e - configure_zle_emacs - fi - - # Allow deleting over the start of insert mode - zle -A .backward-delete-char vi-backward-delete-char -} #}}} - - -function configure_zle_vim #{{{ -{ - # Edit commands in $EDITOR on 'v' in command mode - autoload -Uz edit-command-line - zle -N edit-command-line - bindkey -M vicmd v edit-command-line - - # Use 'jj' to get to Cmd mode - bindkey -M viins 'jj' vi-cmd-mode - - # Backwards incremental history search on ^R in insert mode - bindkey -M viins '^R' history-incremental-search-backwards - - # Use arrow keys to go up and down lines and/or history in insert mode - bindkey -M viins "^[OA" up-line-or-history - bindkey -M viins "^[[A" up-line-or-history - bindkey -M viins "^[OB" down-line-or-history - bindkey -M viins "^[[B" down-line-or-history -} #}}} - - -function configure_zle_emacs #{{{ -{ - -} #}}} - - -function configure_modules_and_functions #{{{ -{ - local myfpath="$HOME/.zsh/func" - fpath=($myfpath/makers $myfpath $fpath) - - print_info -l 2 "Loading functions in $myfpath" - for func in $myfpath/*; do - if [[ ! -e "$func" ]]; then - continue - fi - - # Skip prompt_* functions; these are handled elsewhere. - if [[ "$func" =~ "/prompt_*" ]]; then - continue - fi - - local fname=`basename $func` - print_info_sub -l 3 "Loading $fname" - autoload $fname - done - - load_module 'makers' -} #}}} - - -function configure_prompt #{{{ -{ - print_info -l 2 "Configuring prompt: $PROMPT_THEME" - autoload -U promptinit - promptinit - prompt $PROMPT_THEME -} #}}} - - -function configure_zsh_aliases #{{{ -{ - print_info -l 3 'Creating ZSH-specific aliases' - - #alias -g nc='netcat' - alias -g lessnw='less -S' - - # suffix aliases - alias -s c='vim' - alias -s tex='vim' - alias -s txt='vim' - alias -s xml='vim' - alias -s jar='java -jar' - - alias bx='bundle exec' -} #}}} - - -function configure_history #{{{ -{ - print_info -l 2 'Setting up history' - setopt \ - APPEND_HISTORY \ - EXTENDED_HISTORY \ - INC_APPEND_HISTORY \ - HIST_FIND_NO_DUPS \ - HIST_IGNORE_SPACE \ - HIST_NO_STORE \ - HIST_IGNORE_DUPS \ - HIST_REDUCE_BLANKS - - HISTSIZE=1000000 - SAVEHIST=1000000 - HISTFILE="$HOME/.zhistory" -} #}}} - - -function configure_completion #{{{ -{ - print_info -l 2 'Initializing completion system' - - autoload -U compinit - compinit - - # Cache completions - zstyle ':completion::complete:*' use-cache 1 - zstyle ':completion::complete:*' cache-path ~/.zsh/cache - - zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} - - # For rm, cp, and mv don't complete if file is on the line already - zstyle ':completion:*:rm:*' ignore-line yes - zstyle ':completion:*:cp:*' ignore-line yes - zstyle ':completion:*:mv:*' ignore-line yes - - # Remove trailing slashes in directory arguments - zstyle ':completion:*' squeeze-slashes true - - # Never select parent directory - zstyle ':completion:*:cd:*' ignore-parents parent pwd - - # Expand partial paths - zstyle ':completion:*' expand 'yes' - - # Show a pretty menu of killable processes - zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' - zstyle ':completion:*:*:kill:*' menu yes select - - # Complete man pages by section - zstyle ':completion:*:manuals' separate-sections true - zstyle ':completion:*:manuals.*' insert-sections true - - # Use git completion for the g function (which is a small wrapper around git; see .rc) - if [[ `whence -w g` =~ "function" ]]; then - compdef g='git' - fi -} #}}} - - -function configure_vcs_info #{{{ -{ - print_info -l 3 'Loading vcs_info' - - autoload -U add-zsh-hook - autoload -Uz vcs_info - - zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn - zstyle ':vcs_info:*' enable git - - zstyle ':vcs_info:git:general:*' formats '%b' - - # Export the current Git branch before every prompt. - function export_gitbranch { - vcs_info general - if [[ "$gitbranches[1]" != "${vcs_info_msg_0_}" ]]; then - export gitbranches=(${vcs_info_msg_0_} $gitbranches[1,4]) - fi - export gitbranch=${vcs_info_msg_0_} - } - - add-zsh-hook precmd export_gitbranch -} #}}} - - -configure_general -#configure_omz -configure_zle -configure_modules_and_functions -configure_zsh_aliases -configure_history -configure_completion -configure_vcs_info -configure_prompt - - -if [ -e $HOME/.zshrc.$SYS ]; then - print_info -l 3 "Sourcing ${SYS}-specific Z Shell settings" - source $HOME/.zshrc.$SYS +shell-log 'Initializing Interactive Environment' + +autoload init_app_environments +autoload init_rc_aliases +autoload init_rc_configure_completion +autoload init_rc_configure_ls +autoload init_rc_configure_prompt +autoload init_rc_configure_zle +autoload init_zsh_options +autoload init_zsh_history +autoload init_zsh_functions + +init_rc_aliases +init_rc_configure_prompt loquacious +init_rc_configure_zle emacs +init_rc_configure_completion +init_zsh_options +init_zsh_history +init_zsh_functions +init_app_environments + +autoload +X init_rc_$SYS +init_rc_$SYS + +# Configure ls with the system ls if it hasn't been done already. +if ! alias ls 2>&1 1>/dev/null; then + init_rc_configure_ls `which ls` fi -if [ -e $HOME/.zshrc.local ]; then - print_info -l 3 "Sourcing local Z Shell settings" - source $HOME/.zshrc.local -fi +autoload g +autoload vi diff --git a/zshrc.darwin b/zshrc.darwin deleted file mode 100644 index f4217d6..0000000 --- a/zshrc.darwin +++ /dev/null @@ -1,10 +0,0 @@ -# zshrc.darwin -# OS X customizations for ZSH -# -# Eryn Wells - -# Open a file/folder in Finder -alias reveal='open -R' - -alias -s app='open' -alias -s xcodeproj='open -a Xcode' diff --git a/zshrc.local b/zshrc.local deleted file mode 100644 index 8c362da..0000000 --- a/zshrc.local +++ /dev/null @@ -1,5 +0,0 @@ -# .zshrc.local -# Local customizations for zsh -# Eryn Wells - -