From 9a52ecb21b3e46630eabe24fae30828ce2e6f414 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 4 Aug 2012 14:48:32 -0400 Subject: [PATCH] Increase heading readability --- modules/completion/init.zsh | 8 ++++++ modules/directory/init.zsh | 7 ++++++ modules/dpkg/init.zsh | 2 ++ modules/editor/init.zsh | 30 ++++++++++++++++++++--- modules/environment/init.zsh | 15 ++++++++++++ modules/history-substring-search/init.zsh | 8 ++++++ modules/history/init.zsh | 10 ++++++++ modules/macports/init.zsh | 5 ++++ modules/osx/init.zsh | 8 ++++++ modules/pacman/init.zsh | 6 +++++ modules/pacman/yaourt.zsh | 4 +++ modules/perl/init.zsh | 6 +++++ modules/rails/init.zsh | 6 +++++ modules/rsync/init.zsh | 3 +++ modules/ruby/init.zsh | 2 ++ modules/screen/init.zsh | 7 ++++++ modules/tmux/init.zsh | 6 +++++ modules/utility/init.zsh | 4 +++ modules/yum/init.zsh | 4 ++- templates/zshenv | 16 +++++++++++- 20 files changed, 152 insertions(+), 5 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index da8b178c..2c067bf2 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -14,6 +14,10 @@ fi # Load and initialize the completion system ignoring insecure directories. autoload -Uz compinit && compinit -i +# +# Options +# + setopt COMPLETE_IN_WORD # Complete from both ends of a word. setopt ALWAYS_TO_END # Move cursor to the end of a completed word. setopt PATH_DIRS # Perform path search even on command names with slashes. @@ -26,6 +30,10 @@ unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. # Treat these characters as part of a word. WORDCHARS='*?_-.[]~&;!#$%^(){}<>' +# +# Styles +# + # Use caching to make completion for cammands such as dpkg and apt usable. zstyle ':completion::complete:*' use-cache on zstyle ':completion::complete:*' cache-path "$HOME/.zcache" diff --git a/modules/directory/init.zsh b/modules/directory/init.zsh index f11651e1..3be411b5 100644 --- a/modules/directory/init.zsh +++ b/modules/directory/init.zsh @@ -6,6 +6,10 @@ # Sorin Ionescu # +# +# Options +# + setopt AUTO_CD # Auto changes to a directory without typing cd. setopt AUTO_PUSHD # Push the old directory onto the stack on cd. setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. @@ -18,7 +22,10 @@ setopt EXTENDED_GLOB # Use extended globbing syntax. unsetopt CLOBBER # Do not overwrite existing files with > and >>. # Use >! and >>! to bypass. +# # Aliases +# + alias d='dirs -v' for index ({1..9}) alias "$index"="cd +${index}"; unset index diff --git a/modules/dpkg/init.zsh b/modules/dpkg/init.zsh index edab6830..939e9100 100644 --- a/modules/dpkg/init.zsh +++ b/modules/dpkg/init.zsh @@ -12,7 +12,9 @@ if (( ! $+commands[dpkg] && ! $+commands[apt-get] )); then return 1 fi +# # Aliases +# # Cleans the cache. alias debc='sudo apt-get clean && sudo apt-get autoclean' diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index b34dc417..69fdb83a 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -45,6 +45,10 @@ if [[ "$TERM" == 'dumb' ]]; then return 1 fi +# +# Options +# + # Beep on error in line editor. setopt BEEP @@ -52,6 +56,10 @@ setopt BEEP autoload -Uz edit-command-line zle -N edit-command-line +# +# Variables +# + # Use human-friendly identifiers. zmodload zsh/terminfo typeset -gA key_info @@ -93,6 +101,10 @@ for key in "$key_info[@]"; do fi done +# +# Functions +# + # Displays editor information. function editor-info { # Clean up previous $editor_info. @@ -191,7 +203,10 @@ zle -N prepend-sudo # Reset to default key bindings. bindkey -d -# Emacs key bindings. +# +# Emacs Key Bindings +# + for key ("$key_info[Escape]"{B,b}) bindkey -M emacs "$key" emacs-backward-word for key ("$key_info[Escape]"{F,f}) bindkey -M emacs "$key" emacs-forward-word bindkey -M emacs "$key_info[Escape]$key_info[Left]" emacs-backward-word @@ -220,7 +235,9 @@ if (( $+widgets[history-incremental-pattern-search-backward] )); then history-incremental-pattern-search-forward fi -# Vi key bindings. +# +# Vi Key Bindings +# # Edit command in an external editor. bindkey -M vicmd "v" edit-command-line @@ -241,7 +258,10 @@ else bindkey -M vicmd "/" history-incremental-search-forward fi -# Emacs and Vi key bindings. +# +# Emacs and Vi Key Bindings +# + for keymap in 'emacs' 'viins'; do bindkey -M "$keymap" "$key_info[Home]" beginning-of-line bindkey -M "$keymap" "$key_info[End]" end-of-line @@ -295,6 +315,10 @@ if zstyle -t ':omz:module:editor' dot-expansion; then bindkey -M isearch . self-insert 2> /dev/null fi +# +# Layout +# + # Set the key layout. zstyle -s ':omz:module:editor' keymap 'keymap' if [[ "$keymap" == (emacs|) ]]; then diff --git a/modules/environment/init.zsh b/modules/environment/init.zsh index cd6f4f76..74eb73d3 100644 --- a/modules/environment/init.zsh +++ b/modules/environment/init.zsh @@ -5,16 +5,25 @@ # Sorin Ionescu # +# # Smart URLs +# + autoload -Uz url-quote-magic zle -N self-insert url-quote-magic +# # General +# + setopt BRACE_CCL # Allow brace character class list expansion. setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. +# # Jobs +# + setopt LONG_LIST_JOBS # List jobs in the long format by default. setopt AUTO_RESUME # Attempt to resume existing job before creating a new process. setopt NOTIFY # Report status of background jobs immediately. @@ -22,13 +31,19 @@ unsetopt BG_NICE # Don't run all background jobs at a lower priority. unsetopt HUP # Don't kill jobs on shell exit. unsetopt CHECK_JOBS # Don't report on jobs when shell exit. +# # Grep +# + if zstyle -t ':omz:environment:grep' color; then export GREP_COLOR='37;45' export GREP_OPTIONS='--color=auto' fi +# # Termcap +# + if zstyle -t ':omz:environment:termcap' color; then export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking. export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold. diff --git a/modules/history-substring-search/init.zsh b/modules/history-substring-search/init.zsh index a0ff287f..3be60aba 100644 --- a/modules/history-substring-search/init.zsh +++ b/modules/history-substring-search/init.zsh @@ -8,6 +8,10 @@ source "${0:h}/external/zsh-history-substring-search.zsh" +# +# Styles +# + if zstyle -t ':omz:module:history-substring-search' case-sensitive; then unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS fi @@ -16,6 +20,10 @@ if ! zstyle -t ':omz:module:history-substring-search' color; then unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_{FOUND,NOT_FOUND} fi +# +# Key Bindings +# + bindkey -M emacs "$key_info[Control]P" history-substring-search-up bindkey -M emacs "$key_info[Control]N" history-substring-search-down bindkey -M vicmd "k" history-substring-search-up diff --git a/modules/history/init.zsh b/modules/history/init.zsh index b140d044..b774e13b 100644 --- a/modules/history/init.zsh +++ b/modules/history/init.zsh @@ -6,10 +6,18 @@ # Sorin Ionescu # +# +# Variables +# + HISTFILE="$HOME/.zhistory" # The path to the history file. HISTSIZE=10000 # The maximum number of events to save in the internal history. SAVEHIST=10000 # The maximum number of events to save in the history file. +# +# Options +# + setopt BANG_HIST # Treat the '!' character specially during expansion. setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. @@ -23,7 +31,9 @@ setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history setopt HIST_VERIFY # Do not execute immediately upon history expansion. setopt HIST_BEEP # Beep when accessing non-existent history. +# # Aliases +# # Lists the ten most used commands. alias history-stat="history . | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" diff --git a/modules/macports/init.zsh b/modules/macports/init.zsh index 49b7d379..4554ca1f 100644 --- a/modules/macports/init.zsh +++ b/modules/macports/init.zsh @@ -11,7 +11,9 @@ if [[ "$OSTYPE" != darwin* ]]; then return 1 fi +# # Paths +# # Set the list of directories that info searches for manuals. infopath=( @@ -31,7 +33,10 @@ path=( $path ) +# # Aliases +# + alias portc='sudo port clean --all installed' alias porti='sudo port install' alias ports='port search' diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index 87ca5d6b..6acbfbc7 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -10,12 +10,20 @@ if [[ "$OSTYPE" != darwin* ]]; then return 1 fi +# +# Aliases +# + # Change directory to the current Finder directory. alias cdf='cd "$(pfd)"' # Push directory to the current Finder directory. alias pushdf='pushd "$(pfd)"' +# +# Functions +# + # Open files in Quick Look. function ql { (( $# > 0 )) && qlmanage -p "$@" &> /dev/null diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index f4145d86..eaa3b7fe 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -14,6 +14,10 @@ if (( ! $+commands[pacman] )); then return 1 fi +# +# Frontend +# + # Get the Pacman frontend. zstyle -s ':omz:module:pacman' frontend '_pacman_frontend' @@ -25,7 +29,9 @@ if (( $+commands[$_pacman_frontend] )); then fi fi +# # Aliases +# # Installs packages from repositories. alias paci='sudo pacman --sync' diff --git a/modules/pacman/yaourt.zsh b/modules/pacman/yaourt.zsh index f784a735..b17424e9 100644 --- a/modules/pacman/yaourt.zsh +++ b/modules/pacman/yaourt.zsh @@ -5,6 +5,10 @@ # Sorin Ionescu # +# +# Aliases +# + # Disable color. if ! zstyle -t ':omz:module:pacman:yaourt' color; then alias pacman='pacman --nocolor' diff --git a/modules/perl/init.zsh b/modules/perl/init.zsh index 4278135c..3e4f7e8e 100644 --- a/modules/perl/init.zsh +++ b/modules/perl/init.zsh @@ -10,6 +10,10 @@ if (( ! $+commands[perl] )); then return 1 fi +# +# Local Module Installation +# + if [[ "$OSTYPE" == darwin* ]]; then # Perl is slow; cache its output. cache_file="${0:h}/cache.zsh" @@ -35,7 +39,9 @@ if [[ "$OSTYPE" == darwin* ]]; then unset env_var fi +# # Aliases +# # General alias pd='perldoc' diff --git a/modules/rails/init.zsh b/modules/rails/init.zsh index 81bbbeeb..ee6f2739 100644 --- a/modules/rails/init.zsh +++ b/modules/rails/init.zsh @@ -12,7 +12,10 @@ if (( ! $+commands[rails] )); then return 1 fi +# # Aliases (Compatible with Rails 2) +# + alias rc='_rails-command console' alias rdc='_rails-command dbconsole' alias rdm='rake db:migrate' @@ -27,7 +30,10 @@ alias rs='_rails-command server' alias rsd='_rails-command server --debugger' alias rx='_rails-command destroy' +# # Functions +# + function _rails-command { if [[ -e "script/server" ]]; then ruby script/"$@" diff --git a/modules/rsync/init.zsh b/modules/rsync/init.zsh index 7667472f..c3b3b577 100644 --- a/modules/rsync/init.zsh +++ b/modules/rsync/init.zsh @@ -10,7 +10,10 @@ if (( ! $+commands[rsync] )); then return 1 fi +# # Aliases +# + _rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system' # Mac OS X and HFS+ Enhancements diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 0e7f2264..69ee51bc 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -36,7 +36,9 @@ else fi fi +# # Aliases +# # Bundler if (( $+commands[bundle] )); then diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index 82f3fb21..d185233c 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -10,7 +10,10 @@ if (( ! $+commands[screen] )); then return 1 fi +# # Auto Start +# + if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then session="$( screen -list 2> /dev/null \ @@ -25,7 +28,11 @@ if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then fi fi +# # Aliases +# + alias sl="screen -list" alias sn="screen -U -S" alias sr="screen -a -A -U -D -R" + diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index 9a6c752a..d315aa2c 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -11,7 +11,10 @@ if (( ! $+commands[tmux] )); then return 1 fi +# # Auto Start +# + if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then tmux_session='#OMZ' @@ -33,6 +36,9 @@ if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then exec tmux new-session -t "$tmux_session" fi +# # Aliases +# + alias ta="tmux attach-session" alias tl="tmux list-sessions" diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index b66db8a7..f4563a03 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -13,7 +13,9 @@ omodload 'spectrum' # Correct commands. setopt CORRECT +# # Aliases +# # Disable correction. alias ack='nocorrect ack' @@ -128,7 +130,9 @@ fi # Serves a directory via HTTP. alias http-serve='python -m SimpleHTTPServer' +# # Functions +# # Makes a directory and changes to it. function mkdcd { diff --git a/modules/yum/init.zsh b/modules/yum/init.zsh index bbee6cca..d7019cd0 100644 --- a/modules/yum/init.zsh +++ b/modules/yum/init.zsh @@ -11,7 +11,10 @@ if (( ! $+commands[yum] )); then return 1 fi +# # Aliases +# + alias yumc='sudo yum clean all' # Cleans the cache. alias yumh='yum history' # Displays history. alias yumi='sudo yum install' # Installs package(s). @@ -23,4 +26,3 @@ alias yums='yum search' # Searches for a package. alias yumu='sudo yum update' # Updates packages. alias yumU='sudo yum upgrade' # Upgrades packages. - diff --git a/templates/zshenv b/templates/zshenv index af83ce06..827be56e 100644 --- a/templates/zshenv +++ b/templates/zshenv @@ -8,7 +8,10 @@ # Set the path to Oh My Zsh. export OMZ="$HOME/.oh-my-zsh" +# # Paths +# + typeset -gU cdpath fpath mailpath manpath path typeset -gUT INFOPATH infopath @@ -49,22 +52,33 @@ for path_file in /etc/paths.d/*(.N); do done unset path_file +# # Language +# + if [[ -z "$LANG" ]]; then eval "$(locale)" fi +# # Editors +# + export EDITOR='nano' export VISUAL='nano' export PAGER='less' -# Browser (Default) +# +# Browser +# + if [[ "$OSTYPE" == darwin* ]]; then export BROWSER='open' fi +# # Less +# # Set the default Less options. # Mouse-wheel scrolling has been disabled by -X (disable screen clearing).