├── .gitignore ├── modules ├── utility │ ├── functions │ │ ├── _dut │ │ ├── _cdls_popdls_pushdls │ │ ├── _mkdcd │ │ ├── make │ │ ├── _prep │ │ ├── _psub │ │ ├── diff │ │ ├── dut │ │ ├── wdiff │ │ ├── prep │ │ └── psub │ ├── README.md │ └── init.zsh ├── osx │ ├── functions │ │ ├── _manb_mand_manp │ │ ├── ql │ │ ├── osx-rm-dir-metadata │ │ ├── pfd │ │ ├── manp │ │ ├── pfs │ │ ├── osx-rm-download-history │ │ ├── osx-ls-download-history │ │ ├── mand │ │ └── tab │ ├── init.zsh │ └── README.md ├── git │ ├── functions │ │ ├── _git-hub-shorten-url │ │ ├── git-dir │ │ ├── git-root │ │ ├── git-branch-current │ │ ├── _git-info │ │ ├── git-stash-recover │ │ ├── git-hub-shorten-url │ │ ├── git-commit-lost │ │ ├── git-stash-dropped │ │ ├── _git-submodule-remove │ │ ├── git-stash-clear-interactive │ │ ├── git-submodule-move │ │ ├── git-submodule-remove │ │ ├── _git-submodule-move │ │ ├── _git-hub-browse │ │ └── git-hub-browse │ ├── init.zsh │ └── alias.zsh ├── wakeonlan │ ├── functions │ │ ├── _wake │ │ └── wake │ └── README.md ├── node │ ├── functions │ │ ├── node-doc │ │ └── node-info │ ├── init.zsh │ └── README.md ├── ocaml │ ├── init.zsh │ └── README.md ├── pacman │ ├── yaourt.zsh │ ├── functions │ │ ├── pacman-list-explicit │ │ └── pacman-list-disowned │ ├── README.md │ └── init.zsh ├── dpkg │ ├── functions │ │ ├── deb-kbuild │ │ ├── deb-clone │ │ └── deb-history │ ├── README.md │ └── init.zsh ├── archive │ ├── functions │ │ ├── _unarchive │ │ ├── _lsarchive │ │ ├── lsarchive │ │ └── unarchive │ └── README.md ├── ruby │ ├── functions │ │ ├── ruby-app-root │ │ └── ruby-info │ ├── init.zsh │ └── README.md ├── prompt │ ├── init.zsh │ ├── functions │ │ ├── prompt_minimal_setup │ │ ├── prompt_nicoulaj_setup │ │ ├── prompt_peepcode_setup │ │ ├── prompt_jason_setup │ │ ├── prompt_steeef_setup │ │ └── prompt_sorin_setup │ └── README.md ├── haskell │ ├── init.zsh │ └── README.md ├── command-not-found │ ├── README.md │ └── init.zsh ├── homebrew │ ├── init.zsh │ └── README.md ├── emacs │ ├── init.zsh │ └── README.md ├── environment │ ├── README.md │ └── init.zsh ├── python │ ├── functions │ │ └── python-info │ ├── init.zsh │ └── README.md ├── completion │ ├── README.md │ └── init.zsh ├── yum │ ├── README.md │ └── init.zsh ├── gpg │ ├── README.md │ └── init.zsh ├── macports │ ├── README.md │ └── init.zsh ├── ssh │ ├── README.md │ └── init.zsh ├── helper │ ├── README.md │ ├── init.zsh │ └── functions │ │ └── add-zsh-trap ├── rsync │ ├── README.md │ └── init.zsh ├── gnu-utility │ ├── README.md │ └── init.zsh ├── syntax-highlighting │ ├── init.zsh │ └── README.md ├── screen │ ├── init.zsh │ └── README.md ├── rails │ ├── init.zsh │ └── README.md ├── directory │ ├── init.zsh │ └── README.md ├── fasd │ ├── README.md │ └── init.zsh ├── perl │ ├── init.zsh │ └── README.md ├── tmux │ ├── init.zsh │ └── README.md ├── terminal │ ├── README.md │ └── init.zsh ├── history │ ├── init.zsh │ └── README.md ├── history-substring-search │ ├── init.zsh │ └── README.md ├── editor │ ├── README.md │ └── init.zsh ├── spectrum │ ├── init.zsh │ └── README.md └── README.md ├── runcoms ├── zlogout ├── zshenv ├── zlogin ├── zprofile ├── zshrc ├── README.md └── zpreztorc ├── .gitmodules ├── CONTRIBUTING.md ├── init.zsh └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.zwc 2 | *.zwc.old 3 | modules/*/cache.zsh 4 | -------------------------------------------------------------------------------- /modules/utility/functions/_dut: -------------------------------------------------------------------------------- 1 | #compdef dut 2 | #autoload 3 | 4 | # 5 | # Completes dut. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _du 12 | 13 | -------------------------------------------------------------------------------- /modules/osx/functions/_manb_mand_manp: -------------------------------------------------------------------------------- 1 | #compdef mand manp 2 | #autoload 3 | 4 | # 5 | # Completes mand and manp. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _man 12 | 13 | -------------------------------------------------------------------------------- /modules/osx/functions/ql: -------------------------------------------------------------------------------- 1 | # 2 | # Previews files in Quick Look. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if (( $# > 0 )); then 9 | qlmanage -p "$@" &> /dev/null 10 | fi 11 | -------------------------------------------------------------------------------- /modules/utility/functions/_cdls_popdls_pushdls: -------------------------------------------------------------------------------- 1 | #compdef cdls popdls pushdls 2 | #autoload 3 | 4 | # 5 | # Completes cdls, popdls, and pushdls. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _cd 12 | 13 | -------------------------------------------------------------------------------- /modules/git/functions/_git-hub-shorten-url: -------------------------------------------------------------------------------- 1 | #compdef git-hub-shorten-url 2 | #autoload 3 | 4 | # 5 | # Completes git-hub-shorten-url. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _arguments '1:url:' && return 0 12 | 13 | -------------------------------------------------------------------------------- /runcoms/zlogout: -------------------------------------------------------------------------------- 1 | # 2 | # Executes commands at logout. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Print the message. 9 | cat <<-EOF 10 | 11 | Thank you. Come again! 12 | -- Dr. Apu Nahasapeemapetilon 13 | EOF 14 | 15 | -------------------------------------------------------------------------------- /modules/utility/functions/_mkdcd: -------------------------------------------------------------------------------- 1 | #compdef mkdcd 2 | #autoload 3 | 4 | # 5 | # Completes mkdcd. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | local expl 12 | 13 | _wanted directories expl 'directory' _path_files -/ || _message 'directory' 14 | 15 | -------------------------------------------------------------------------------- /modules/wakeonlan/functions/_wake: -------------------------------------------------------------------------------- 1 | #compdef wake 2 | #autoload 3 | 4 | # 5 | # Completes wake. 6 | # 7 | # Authors: 8 | # Paul Gideon Dann 9 | # Sorin Ionescu 10 | # 11 | 12 | _arguments "1:device to wake:_files -W '$HOME/.wakeonlan'" && return 0 13 | 14 | -------------------------------------------------------------------------------- /modules/osx/functions/osx-rm-dir-metadata: -------------------------------------------------------------------------------- 1 | # 2 | # Deletes .DS_Store and __MACOSX directories. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | find "${@:-$PWD}" \( \ 9 | -type f -name '.DS_Store' -o \ 10 | -type d -name '__MACOSX' \ 11 | \) -print0 | xargs -0 rm -rf 12 | -------------------------------------------------------------------------------- /modules/osx/functions/pfd: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the current Finder.app directory. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | osascript 2>/dev/null < 6 | # 7 | 8 | # TODO: Make the sections easier to use. 9 | open "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}" 10 | 11 | -------------------------------------------------------------------------------- /modules/ocaml/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Initializes Ocaml package management. 3 | # 4 | # Authors: 5 | # Sebastian Wiesner 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[opam] )); then 10 | return 1 11 | fi 12 | 13 | # Initialize OPAM. 14 | eval "$(opam config env)" 15 | 16 | -------------------------------------------------------------------------------- /runcoms/zshenv: -------------------------------------------------------------------------------- 1 | # 2 | # Defines environment variables. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Ensure that a non-login, non-interactive shell has a defined environment. 9 | if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then 10 | source "${ZDOTDIR:-$HOME}/.zprofile" 11 | fi 12 | 13 | -------------------------------------------------------------------------------- /modules/git/functions/git-dir: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the path to the Git directory. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local git_dir="${$(git rev-parse --git-dir):A}" 9 | 10 | if [[ -n "$git_dir" ]]; then 11 | print "$git_dir" 12 | return 0 13 | else 14 | print "$0: not a repository: $PWD" >&2 15 | return 1 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /modules/pacman/yaourt.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Yaourt aliases. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # Aliases 10 | # 11 | 12 | # Disable color. 13 | if ! zstyle -t ':prezto:module:pacman:yaourt' color; then 14 | alias pacman='yaourt --nocolor' 15 | fi 16 | 17 | # Manages .pac* files. 18 | alias pacc='yaourt -C' 19 | 20 | -------------------------------------------------------------------------------- /modules/git/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Provides Git aliases and functions. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[git] )); then 10 | return 1 11 | fi 12 | 13 | # Load dependencies. 14 | pmodload 'helper' 15 | 16 | # Source module files. 17 | source "${0:h}/alias.zsh" 18 | 19 | -------------------------------------------------------------------------------- /modules/dpkg/functions/deb-kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Makes a dpkg Linux kernel package. 3 | # 4 | # Authors: 5 | # Daniel Bolton 6 | # Sorin Ionescu 7 | # 8 | 9 | make-kpkg clean 10 | MAKEFLAGS='' time fakeroot make-kpkg \ 11 | --append-to-version '-custom' \ 12 | --revision "$(date +"%Y%m%d")" \ 13 | kernel_image \ 14 | kernel_headers 15 | 16 | -------------------------------------------------------------------------------- /modules/archive/functions/_unarchive: -------------------------------------------------------------------------------- 1 | #compdef unarchive 2 | #autoload 3 | 4 | # 5 | # Completes unarchive. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _arguments \ 12 | '(-r --remove)'{-r,--remove}'[remove archive]' \ 13 | "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0 14 | 15 | -------------------------------------------------------------------------------- /modules/archive/functions/_lsarchive: -------------------------------------------------------------------------------- 1 | #compdef lsarchive 2 | #autoload 3 | 4 | # 5 | # Completes lsarchive. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _arguments \ 12 | '(-v --verbose)'{-v,--remove}'[verbose archive listing]' \ 13 | "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z)(-.)'" && return 0 14 | 15 | -------------------------------------------------------------------------------- /modules/git/functions/git-root: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the path to the working tree root. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local root="$(git rev-parse --show-toplevel 2> /dev/null)" 9 | 10 | if [[ -n "$root" ]]; then 11 | print "$root" 12 | return 0 13 | else 14 | print "$0: not a repository work tree: $PWD" >&2 15 | return 1 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /modules/osx/functions/manp: -------------------------------------------------------------------------------- 1 | # 2 | # Opens man pages in Preview.app. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | function manp { 9 | local page 10 | if (( $# > 0 )); then 11 | for page in "$@"; do 12 | man -t "$page" | open -f -a Preview 13 | done 14 | else 15 | print 'What manual page do you want?' >&2 16 | fi 17 | } 18 | 19 | manp "$@" 20 | 21 | -------------------------------------------------------------------------------- /modules/osx/functions/pfs: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the current Finder.app selection. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | osascript 2>&1 < 6 | # 7 | 8 | local root_dir="$PWD" 9 | 10 | while [[ "$root_dir" != '/' ]]; do 11 | if [[ -f "$root_dir/Gemfile" ]]; then 12 | print "$root_dir" 13 | break 14 | fi 15 | root_dir="$root_dir:h" 16 | done 17 | 18 | return 1 19 | 20 | -------------------------------------------------------------------------------- /modules/osx/functions/osx-rm-download-history: -------------------------------------------------------------------------------- 1 | # 2 | # Deletes the Mac OS X download history. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local db 9 | for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do 10 | if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then 11 | sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM' 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /modules/utility/functions/make: -------------------------------------------------------------------------------- 1 | # 2 | # Highlights make output. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | function make { 9 | if zstyle -t ':prezto:module:utility:make' color; then 10 | if (( $+commands[colormake] )); then 11 | colormake "$@" 12 | else 13 | command make "$@" 14 | fi 15 | else 16 | command make "$@" 17 | fi 18 | } 19 | 20 | make "$@" 21 | 22 | -------------------------------------------------------------------------------- /modules/osx/functions/osx-ls-download-history: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the Mac OS X download history. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local db 9 | for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do 10 | if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then 11 | sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent' 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /modules/utility/functions/_prep: -------------------------------------------------------------------------------- 1 | #compdef prep 2 | #autoload 3 | 4 | # 5 | # Completes prep. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _arguments \ 12 | '-i[ignore case]' \ 13 | '-m[^ and $ match the start and the end of a line]' \ 14 | '-s[. matches newline]' \ 15 | '-v[invert match]' \ 16 | '-x[ignore whitespace and comments]' \ 17 | '1::pattern:' \ 18 | '2::files:_files' && return 0 19 | 20 | -------------------------------------------------------------------------------- /modules/git/functions/git-branch-current: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the current Git branch. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! git rev-parse 2> /dev/null; then 9 | print "$0: not a repository: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | local ref="$(git symbolic-ref HEAD 2> /dev/null)" 14 | 15 | if [[ -n "$ref" ]]; then 16 | print "${ref#refs/heads/}" 17 | return 0 18 | else 19 | return 1 20 | fi 21 | 22 | -------------------------------------------------------------------------------- /modules/osx/functions/mand: -------------------------------------------------------------------------------- 1 | # 2 | # Opens man pages in Dash.app. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | function mand { 9 | if (( $# > 0 )); then 10 | open "dash://manpages:$1" 2>/dev/null 11 | if (( $? != 0 )); then 12 | print "$0: Dash is not installed" >&2 13 | break 14 | fi 15 | else 16 | print 'What manual page do you want?' >&2 17 | fi 18 | } 19 | 20 | mand "$@" 21 | 22 | -------------------------------------------------------------------------------- /modules/prompt/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Loads prompt themes. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Load and execute the prompt theming system. 9 | autoload -Uz promptinit && promptinit 10 | 11 | # Load the prompt theme. 12 | zstyle -a ':prezto:module:prompt' theme 'prompt_argv' 13 | if (( $#prompt_argv > 0 )); then 14 | prompt "$prompt_argv[@]" 15 | else 16 | prompt 'off' 17 | fi 18 | unset prompt_argv 19 | 20 | -------------------------------------------------------------------------------- /modules/pacman/functions/pacman-list-explicit: -------------------------------------------------------------------------------- 1 | # 2 | # Lists explicitly installed Pacman packages. 3 | # 4 | # Authors: 5 | # Benjamin Boudreau 6 | # Sorin Ionescu 7 | # 8 | 9 | pacman --query --explicit --info \ 10 | | awk ' 11 | BEGIN { 12 | FS=":" 13 | } 14 | /^Name/ { 15 | print $2 16 | } 17 | /^Description/ { 18 | print $2 19 | } 20 | ' 21 | 22 | -------------------------------------------------------------------------------- /modules/osx/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Mac OS X aliases and functions. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if [[ "$OSTYPE" != darwin* ]]; then 10 | return 1 11 | fi 12 | 13 | # 14 | # Aliases 15 | # 16 | 17 | # Changes directory to the current Finder directory. 18 | alias cdf='cd "$(pfd)"' 19 | 20 | # Pushes directory to the current Finder directory. 21 | alias pushdf='pushd "$(pfd)"' 22 | -------------------------------------------------------------------------------- /modules/utility/functions/_psub: -------------------------------------------------------------------------------- 1 | #compdef psub 2 | #autoload 3 | 4 | # 5 | # Completes psub. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | _arguments \ 12 | '-g[match globally]' \ 13 | '-i[ignore case]' \ 14 | '-m[^ and $ match the start and the end of a line]' \ 15 | '-s[. matches newline]' \ 16 | '-x[ignore whitespace and comments]' \ 17 | '1::pattern:' \ 18 | '2::replacement:' \ 19 | '3::files:_files' && return 0 20 | 21 | -------------------------------------------------------------------------------- /modules/git/functions/_git-info: -------------------------------------------------------------------------------- 1 | #compdef git-info 2 | #autoload 3 | 4 | # 5 | # Completes git-info. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 12 | return 1 13 | fi 14 | 15 | _arguments "1:toggle:(( 16 | on\:'enable in-prompt information for the current repository' 17 | off\:'disable in-prompt information for the current repository' 18 | ))" && return 0 19 | 20 | -------------------------------------------------------------------------------- /modules/git/functions/git-stash-recover: -------------------------------------------------------------------------------- 1 | # 2 | # Recovers dropped Git stashed states. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | local commit 14 | 15 | for commit in "$@"; do 16 | git update-ref \ 17 | -m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" 18 | done 19 | 20 | -------------------------------------------------------------------------------- /modules/haskell/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Enables local Haskell package installation. 3 | # 4 | # Authors: 5 | # Sebastian Wiesner 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[ghc] )); then 10 | return 1 11 | fi 12 | 13 | # Prepend Cabal per user directories to PATH. 14 | if [[ "$OSTYPE" == darwin* && -d $HOME/Library/Haskell ]]; then 15 | path=($HOME/Library/Haskell/bin(/N) $path) 16 | else 17 | path=($HOME/.cabal/bin(/N) $path) 18 | fi 19 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "modules/history-substring-search/external"] 2 | path = modules/history-substring-search/external 3 | url = https://github.com/zsh-users/zsh-history-substring-search.git 4 | [submodule "modules/syntax-highlighting/external"] 5 | path = modules/syntax-highlighting/external 6 | url = https://github.com/zsh-users/zsh-syntax-highlighting.git 7 | [submodule "modules/completion/external"] 8 | path = modules/completion/external 9 | url = https://github.com/zsh-users/zsh-completions.git 10 | -------------------------------------------------------------------------------- /modules/wakeonlan/functions/wake: -------------------------------------------------------------------------------- 1 | # 2 | # Wakes devices via wakeonlan. 3 | # 4 | # Authors: 5 | # Paul Gideon Dann 6 | # Sorin Ionescu 7 | # 8 | 9 | local config_file="$HOME/.wakeonlan/$1" 10 | if [[ ! -s "$config_file" ]]; then 11 | print "$0: invalid device file: $1" >&2 12 | return 1 13 | fi 14 | 15 | if (( ! $+commands[wakeonlan] )); then 16 | print "$0: command not found: wakeonlan" >&2 17 | return 1 18 | fi 19 | 20 | wakeonlan -f "$config_file" 21 | 22 | -------------------------------------------------------------------------------- /modules/git/functions/git-hub-shorten-url: -------------------------------------------------------------------------------- 1 | # 2 | # Shortens GitHub URLs. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local url="$1" 9 | 10 | if [[ "$url" == '-' ]]; then 11 | read url <&0 12 | fi 13 | 14 | if [[ -z "$url" ]]; then 15 | print "usage: $0 [ url | - ]" >&2 16 | fi 17 | 18 | if (( $+commands[curl] )); then 19 | curl -s -i 'http://git.io' -F "url=$url" | grep 'Location:' | sed 's/Location: //' 20 | else 21 | print "$0: command not found: curl" >&2 22 | fi 23 | 24 | -------------------------------------------------------------------------------- /modules/command-not-found/README.md: -------------------------------------------------------------------------------- 1 | Command-Not-Found 2 | ================= 3 | 4 | Displays installation information for not found commands by loading the 5 | [command-not-found][1] tool on Debian-based and Arch Linux-based distributions. 6 | 7 | Authors 8 | ------- 9 | 10 | *The authors of this module should be contacted via the [issue tracker][2].* 11 | 12 | - [Joseph Booker](https://github.com/sargas) 13 | 14 | [1]: https://code.launchpad.net/command-not-found 15 | [2]: https://github.com/sorin-ionescu/prezto/issues 16 | 17 | -------------------------------------------------------------------------------- /modules/git/functions/git-commit-lost: -------------------------------------------------------------------------------- 1 | # 2 | # Lists lost Git commits. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | git fsck 2> /dev/null \ 14 | | grep "^dangling commit" \ 15 | | awk '{print $3}' \ 16 | | git log \ 17 | --date-order \ 18 | --no-walk \ 19 | --stdin \ 20 | --pretty=format:${_git_log_oneline_format} 21 | 22 | -------------------------------------------------------------------------------- /modules/homebrew/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Homebrew aliases. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if [[ "$OSTYPE" != darwin* ]]; then 10 | return 1 11 | fi 12 | 13 | # 14 | # Aliases 15 | # 16 | 17 | alias brewc='brew cleanup' 18 | alias brewC='brew cleanup --force' 19 | alias brewi='brew install' 20 | alias brewl='brew list' 21 | alias brews='brew search' 22 | alias brewu='brew upgrade' 23 | alias brewU='brew update && brew upgrade' 24 | alias brewx='brew remove' 25 | 26 | -------------------------------------------------------------------------------- /modules/emacs/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Configures Emacs dependency management. 3 | # 4 | # Authors: Sebastian Wiesner 5 | # 6 | 7 | # Return if requirements are not found. 8 | if [[ ! -d "$HOME/.cask" ]]; then 9 | return 1 10 | fi 11 | 12 | # Prepend Cask bin directory. 13 | path=($HOME/.cask/bin $path) 14 | 15 | # Load Carton completion 16 | source "$HOME/.cask/etc/cask_completion.zsh" 2> /dev/null 17 | 18 | # 19 | # Aliases 20 | # 21 | 22 | alias cai='cask install' 23 | alias cau='cask update' 24 | alias caI='cask init' 25 | alias cae='cask exec' 26 | -------------------------------------------------------------------------------- /modules/pacman/functions/pacman-list-disowned: -------------------------------------------------------------------------------- 1 | # 2 | # Lists Pacman disowned files. 3 | # 4 | # Authors: 5 | # Benjamin Boudreau 6 | # Sorin Ionescu 7 | # 8 | 9 | local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$" 10 | local db="$tmp/db" 11 | local fs="$tmp/fs" 12 | 13 | mkdir "$tmp" 14 | trap 'rm -rf "$tmp"' EXIT 15 | 16 | pacman --quiet --query --list | sort --unique > "$db" 17 | 18 | find /bin /etc /lib /sbin /usr \ 19 | ! -name lost+found \ 20 | \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" 21 | 22 | comm -23 "$fs" "$db" 23 | 24 | -------------------------------------------------------------------------------- /modules/utility/functions/diff: -------------------------------------------------------------------------------- 1 | # 2 | # Highlights diff output. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | function diff { 9 | if zstyle -t ':prezto:module:utility:diff' color; then 10 | if (( $+commands[colordiff] )); then 11 | command diff --unified "$@" | colordiff --difftype diffu 12 | elif (( $+commands[git] )); then 13 | git --no-pager diff --color=auto --no-ext-diff --no-index "$@" 14 | else 15 | command diff --unified "$@" 16 | fi 17 | else 18 | command diff --unified "$@" 19 | fi 20 | } 21 | 22 | diff "$@" 23 | 24 | -------------------------------------------------------------------------------- /modules/command-not-found/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Displays installation information for not found commands. 3 | # 4 | # Authors: 5 | # Joseph Jon Booker 6 | # 7 | 8 | # Load command-not-found on Debian-based distributions. 9 | if [[ -s '/etc/zsh_command_not_found' ]]; then 10 | source '/etc/zsh_command_not_found' 11 | # Load command-not-found on Arch Linux-based distributions. 12 | elif [[ -s '/usr/share/doc/pkgfile/command-not-found.zsh' ]]; then 13 | source '/usr/share/doc/pkgfile/command-not-found.zsh' 14 | # Return if requirements are not found. 15 | else 16 | return 1 17 | fi 18 | 19 | -------------------------------------------------------------------------------- /runcoms/zlogin: -------------------------------------------------------------------------------- 1 | # 2 | # Executes commands at login post-zshrc. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Execute code that does not affect the current session in the background. 9 | { 10 | # Compile the completion dump to increase startup speed. 11 | zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" 12 | if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then 13 | zcompile "$zcompdump" 14 | fi 15 | } &! 16 | 17 | # Print a random, hopefully interesting, adage. 18 | if (( $+commands[fortune] )); then 19 | fortune -a 20 | print 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /modules/git/functions/git-stash-dropped: -------------------------------------------------------------------------------- 1 | # 2 | # Lists dropped Git stashed states. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | git fsck --unreachable 2> /dev/null \ 14 | | grep 'commit' \ 15 | | awk '{print $3}' \ 16 | | git log \ 17 | --pretty=format:${_git_log_oneline_format} \ 18 | --extended-regexp \ 19 | --grep="${1:-(WIP )?[Oo]n [^:]+:}" \ 20 | --merges \ 21 | --no-walk \ 22 | --stdin 23 | 24 | -------------------------------------------------------------------------------- /modules/git/functions/_git-submodule-remove: -------------------------------------------------------------------------------- 1 | #compdef git-submodule-remove 2 | #autoload 3 | 4 | # 5 | # Completes git-submodule-remove. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 12 | return 1 13 | fi 14 | 15 | local -a submodules 16 | local submodule 17 | 18 | while IFS=$'\n' read submodule; do 19 | submodules+=("$submodule") 20 | done < <( 21 | git config --file "$(git-root)/.gitmodules" --list \ 22 | | grep '.path=' \ 23 | | cut -d= -f2- 24 | ) 25 | 26 | _describe -t submodule 'submodules' submodules && return 0 27 | 28 | -------------------------------------------------------------------------------- /modules/git/functions/git-stash-clear-interactive: -------------------------------------------------------------------------------- 1 | # 2 | # Asks for confirmation before clearing the Git stash. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | local stashed 14 | 15 | if [[ -f "$(git-dir)/refs/stash" ]]; then 16 | stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')" 17 | if (( $stashed > 0 )); then 18 | if read -q "?Clear $stashed stashed state(s) [y/N]? "; then 19 | git stash clear 20 | fi 21 | fi 22 | fi 23 | 24 | -------------------------------------------------------------------------------- /modules/environment/README.md: -------------------------------------------------------------------------------- 1 | Environment 2 | =========== 3 | 4 | Sets general shell options and defines environment variables. 5 | 6 | This module must be loaded first. 7 | 8 | Environment Variables 9 | --------------------- 10 | 11 | Contributors 12 | ------------ 13 | 14 | This module **MUST NOT** rely on any command not built in Zsh. 15 | 16 | Non-interactive environment variables should be defined in *zshenv*. 17 | 18 | Authors 19 | ------- 20 | 21 | *The authors of this module should be contacted via the [issue tracker][1].* 22 | 23 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 24 | 25 | [1]: https://github.com/sorin-ionescu/prezto/issues 26 | 27 | -------------------------------------------------------------------------------- /modules/node/functions/node-info: -------------------------------------------------------------------------------- 1 | # 2 | # Exposes information about the Node.js environment via the $node_info 3 | # associative array. 4 | # 5 | # Authors: 6 | # Zeh Rizzatti 7 | # 8 | 9 | local version 10 | local version_format 11 | local version_formatted 12 | 13 | unset node_info 14 | typeset -gA node_info 15 | 16 | if (( $+functions[nvm_version] )); then 17 | version="${$(nvm_version)#v}" 18 | fi 19 | 20 | if [[ -n "$version" ]]; then 21 | zstyle -s ':prezto:module:node:info:version' format 'version_format' 22 | zformat -f version_formatted "$version_format" "v:$version" 23 | node_info[version]="$version_formatted" 24 | fi 25 | 26 | -------------------------------------------------------------------------------- /modules/python/functions/python-info: -------------------------------------------------------------------------------- 1 | # 2 | # Exposes information about the Python environment via the $python_info 3 | # associative array. 4 | # 5 | # Authors: 6 | # Sorin Ionescu 7 | # 8 | 9 | local virtualenv_format 10 | local virtualenv_formatted 11 | 12 | # Clean up previous $python_info. 13 | unset python_info 14 | typeset -gA python_info 15 | 16 | # Format virtualenv. 17 | if [[ -n "$VIRTUAL_ENV" ]]; then 18 | zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format' 19 | zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}" 20 | python_info[virtualenv]="$virtualenv_formatted" 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /modules/ocaml/README.md: -------------------------------------------------------------------------------- 1 | Ocaml 2 | ===== 3 | 4 | Initializes [Ocaml][1] package management. 5 | 6 | OPAM 7 | ---- 8 | 9 | [OPAM][2] is a package manager for Ocaml. 10 | 11 | This module enables local package installation with OPAM by extending the 12 | relevant path and Ocaml variables. 13 | 14 | ### Usage 15 | 16 | Install packages to your local package directory with `opam install`. 17 | 18 | Authors 19 | ------- 20 | 21 | *The authors of this module should be contacted via the [issue tracker][3].* 22 | 23 | - [Sebastian Wiesner](https://github.com/lunaryorn) 24 | 25 | [1]: http://ocaml.org/ 26 | [2]: http://opam.ocamlpro.com/ 27 | [3]: https://github.com/sorin-ionescu/prezto/issues 28 | 29 | -------------------------------------------------------------------------------- /modules/utility/functions/dut: -------------------------------------------------------------------------------- 1 | # 2 | # Displays the grand total disk usage using human readable units. 3 | # 4 | # Authors: 5 | # Suraj N. Kurapati 6 | # Sorin Ionescu 7 | # 8 | 9 | function dut { 10 | (( $# == 0 )) && set -- * 11 | 12 | if grep -q -i 'GNU' < <(du --version 2>&1); then 13 | du -khsc "$@" | sort -h -r 14 | else 15 | local line size name 16 | local -a record 17 | 18 | while IFS=$'\n' read line; do 19 | record=(${(z)line}) 20 | size="$(($record[1] / 1024.0))" 21 | name="$record[2,-1]" 22 | printf "%9.1LfM %s\n" "$size" "$name" 23 | done < <(du -kcs "$@") | sort -n -r 24 | fi 25 | } 26 | 27 | dut "$@" 28 | 29 | -------------------------------------------------------------------------------- /modules/dpkg/functions/deb-clone: -------------------------------------------------------------------------------- 1 | # 2 | # Generates a script that can be used to duplicate a dpkg-based system. 3 | # 4 | # Authors: 5 | # Daniel Bolton 6 | # Sorin Ionescu 7 | # 8 | 9 | local clone_script="${0}.sh" 10 | local package_list=$( 11 | perl \ 12 | -m 'AptPkg::Cache' \ 13 | -e ' 14 | $c=AptPkg::Cache->new; 15 | for (keys %$c) { 16 | push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed'; 17 | } 18 | print "$_ " for sort @a; 19 | ' 20 | ) 21 | 22 | rm "$clone_script" 23 | print '#!/bin/sh\n' > "$clone_script" 24 | print "aptitude install ${package_list}\n" >> "$clone_script" 25 | chmod +x "$clone_script" 26 | 27 | -------------------------------------------------------------------------------- /modules/completion/README.md: -------------------------------------------------------------------------------- 1 | Completion 2 | ========== 3 | 4 | Loads and configures tab completion and provides additional completions from 5 | the [zsh-completions][1] project. 6 | 7 | This module must be loaded **after** the *utility* module. 8 | 9 | Contributors 10 | ------------ 11 | 12 | Completions should be submitted to the [zsh-completions][1] project according 13 | to its rules and regulations. This module will be synchronized against it. 14 | 15 | Authors 16 | ------- 17 | 18 | *The authors of this module should be contacted via the [issue tracker][2].* 19 | 20 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 21 | 22 | [1]: https://github.com/zsh-users/zsh-completions 23 | [2]: https://github.com/sorin-ionescu/prezto/issues 24 | 25 | -------------------------------------------------------------------------------- /modules/homebrew/README.md: -------------------------------------------------------------------------------- 1 | Homebrew 2 | ======== 3 | 4 | Defines Homebrew aliases. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `brewc` cleans outdated brews and their cached archives. 10 | - `brewC` cleans outdated brews, including keg-only, and their cached archives. 11 | - `brewi` installs a formula. 12 | - `brewl` lists installed formulae. 13 | - `brews` searches for a formula. 14 | - `brewU` upgrades Homebrew and outdated brews. 15 | - `brewu` upgrades Homebrew. 16 | - `brewx` uninstalls a formula. 17 | 18 | Authors 19 | ------- 20 | 21 | *The authors of this module should be contacted via the [issue tracker][1].* 22 | 23 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 24 | 25 | [1]: https://github.com/sorin-ionescu/prezto/issues 26 | 27 | -------------------------------------------------------------------------------- /modules/yum/README.md: -------------------------------------------------------------------------------- 1 | Yum 2 | === 3 | 4 | Defines [yum][1] aliases. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `yumc` removes package(s) and leaves. 10 | - `yumi` installs package(s). 11 | - `yumh` displays history. 12 | - `yuml` lists packages. 13 | - `yumL` lists installed packages. 14 | - `yumq` displays package information. 15 | - `yumr` removes package(s). 16 | - `yums` searches for a package. 17 | - `yumu` updates packages. 18 | - `yumU` upgrates packages. 19 | 20 | Authors 21 | ------- 22 | 23 | *The authors of this module should be contacted via the [issue tracker][2].* 24 | 25 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 26 | 27 | [1]: http://yum.baseurl.org 28 | [2]: https://github.com/sorin-ionescu/prezto/issues 29 | 30 | -------------------------------------------------------------------------------- /modules/gpg/README.md: -------------------------------------------------------------------------------- 1 | GPG 2 | === 3 | 4 | Provides for an easier use of [GPG][1] by setting up [gpg-agent][2]. 5 | 6 | ### SSH 7 | 8 | To enable OpenSSH Agent protocol emulation, and make `gpg-agent` a drop-in 9 | replacement for `ssh-agent`, add the following line to 10 | *~/.gnupg/gpg-agent.conf*: 11 | 12 | enable-ssh-support 13 | 14 | When OpenSSH Agent protocol emulation is enabled, this module will load the SSH 15 | module for additional processing. 16 | 17 | Authors 18 | ------- 19 | 20 | *The authors of this module should be contacted via the [issue tracker][3].* 21 | 22 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 23 | 24 | [1]: http://www.gnupg.org 25 | [2]: http://linux.die.net/man/1/gpg-agent 26 | [3]: https://github.com/sorin-ionescu/prezto/issues 27 | 28 | -------------------------------------------------------------------------------- /modules/macports/README.md: -------------------------------------------------------------------------------- 1 | Macports 2 | ======== 3 | 4 | Defines MacPorts aliases and adds MacPorts directories to path variables. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `portc` cleans the files used to build ports. 10 | - `porti` installs a port. 11 | - `ports` searches for a port. 12 | - `portu` upgrades a port. 13 | - `portU` upgrades MacPorts, the ports collection, and outdated ports. 14 | - `portx` uninstalls a port. 15 | - `portX` uninstalls inactive ports. 16 | 17 | Authors 18 | ------- 19 | 20 | *The authors of this module should be contacted via the [issue tracker][1].* 21 | 22 | - [Matt Cable](https://github.com/curiousstranger) 23 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 24 | 25 | [1]: https://github.com/sorin-ionescu/prezto/issues 26 | 27 | -------------------------------------------------------------------------------- /modules/ssh/README.md: -------------------------------------------------------------------------------- 1 | SSH 2 | === 3 | 4 | Provides for an easier use of [SSH][1] by setting up [ssh-agent][2]. 5 | 6 | This module is disabled on Mac OS X due to custom Apple SSH support rendering it 7 | unnecessary. 8 | 9 | Settings 10 | -------- 11 | 12 | ### Identities 13 | 14 | To load multiple identities, add the following line to *zpreztorc*: 15 | 16 | zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_dsa' 'id_github' 17 | 18 | Authors 19 | ------- 20 | 21 | *The authors of this module should be contacted via the [issue tracker][3].* 22 | 23 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 24 | 25 | [1]: http://www.openssh.com 26 | [2]: http://www.openbsd.org/cgi-bin/man.cgi?query=ssh-agent&sektion=1 27 | [3]: https://github.com/sorin-ionescu/prezto/issues 28 | 29 | -------------------------------------------------------------------------------- /modules/helper/README.md: -------------------------------------------------------------------------------- 1 | Helper 2 | ====== 3 | 4 | Provides helper functions for developing modules. 5 | 6 | Functions 7 | --------- 8 | 9 | - `add-zsh-trap` adds a function name to a list to be called when a trap is 10 | triggered. 11 | - `is-autoloadable` checks if a file can be autoloaded by trying to load it 12 | in a subshell. 13 | - `is-callable` checks if a name is a command, function, or alias. 14 | - `is-true` checks a boolean variable for "true". 15 | - `coalesce` prints the first non-empty string in the arguments array. 16 | 17 | Authors 18 | ------- 19 | 20 | *The authors of this module should be contacted via the [issue tracker][1].* 21 | 22 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 23 | 24 | [1]: https://github.com/sorin-ionescu/prezto/issues 25 | 26 | -------------------------------------------------------------------------------- /modules/node/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Loads the Node Version Manager and enables npm completion. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # Zeh Rizzatti 7 | # 8 | 9 | # Load NVM into the shell session. 10 | if [[ -s "$HOME/.nvm/nvm.sh" ]]; then 11 | source "$HOME/.nvm/nvm.sh" 12 | fi 13 | 14 | # Return if requirements are not found. 15 | if (( ! $+commands[node] )); then 16 | return 1 17 | fi 18 | 19 | # Load NPM completion. 20 | if (( $+commands[npm] )); then 21 | cache_file="${0:h}/cache.zsh" 22 | 23 | if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then 24 | # npm is slow; cache its output. 25 | npm completion >! "$cache_file" 2> /dev/null 26 | fi 27 | 28 | source "$cache_file" 29 | 30 | unset cache_file 31 | fi 32 | 33 | -------------------------------------------------------------------------------- /modules/git/functions/git-submodule-move: -------------------------------------------------------------------------------- 1 | # 2 | # Moves a Git submodule. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | elif [[ "$PWD" != "$(git-root)" ]]; then 12 | print "$0: must be run from the root of the work tree" >&2 13 | return 1 14 | fi 15 | 16 | local src="$1" 17 | local dst="$2" 18 | local url 19 | 20 | url="$(git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")" 21 | 22 | if [[ -z "$url" ]]; then 23 | print "$0: submodule not found: $src" >&2 24 | return 1 25 | fi 26 | 27 | mkdir -p "${dst:h}" 28 | 29 | git-submodule-remove "$src" 30 | git submodule add "$url" "$dst" 31 | 32 | return 0 33 | 34 | -------------------------------------------------------------------------------- /modules/haskell/README.md: -------------------------------------------------------------------------------- 1 | Haskell 2 | ======= 3 | 4 | Enables local Haskell package installation. 5 | 6 | Per-user Package Installation 7 | ----------------------------- 8 | 9 | [Cabal][1], the Haskell package manager, can install packages into per user 10 | directories. 11 | 12 | This module prepends per user directories to the relevant path variables to 13 | enable the execution of user installed executables and the reading of 14 | documentation. 15 | 16 | ### Usage 17 | 18 | Install packages into per user directories with `cabal install --user`. 19 | 20 | Authors 21 | ------- 22 | 23 | *The authors of this module should be contacted via the [issue tracker][2].* 24 | 25 | - [Sebastian Wiesner](https://github.com/lunaryorn) 26 | 27 | [1]: http://www.haskell.org/cabal/ 28 | [2]: https://github.com/sorin-ionescu/prezto/issues 29 | 30 | -------------------------------------------------------------------------------- /modules/macports/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines MacPorts aliases and adds MacPorts directories to path variables. 3 | # 4 | # Authors: 5 | # Matt Cable 6 | # Sorin Ionescu 7 | # 8 | 9 | # Return if requirements are not found. 10 | if [[ "$OSTYPE" != darwin* ]]; then 11 | return 1 12 | fi 13 | 14 | # 15 | # Paths 16 | # 17 | 18 | # Set the list of directories that Zsh searches for programs. 19 | path=( 20 | /opt/local/{bin,sbin} 21 | $path 22 | ) 23 | 24 | # 25 | # Aliases 26 | # 27 | 28 | alias portc='sudo port clean --all installed' 29 | alias porti='sudo port install' 30 | alias ports='port search' 31 | alias portU='sudo port selfupdate && sudo port upgrade outdated' 32 | alias portu='sudo port upgrade' 33 | alias portX='sudo port -u uninstall' 34 | alias portx='sudo port uninstall' 35 | 36 | -------------------------------------------------------------------------------- /modules/ruby/functions/ruby-info: -------------------------------------------------------------------------------- 1 | # 2 | # Exposes information about the Ruby environment via the $ruby_info associative 3 | # array. 4 | # 5 | # Authors: 6 | # Sorin Ionescu 7 | # 8 | 9 | local version 10 | local version_format 11 | local version_formatted 12 | 13 | # Clean up previous $ruby_info. 14 | unset ruby_info 15 | typeset -gA ruby_info 16 | 17 | if (( $+commands[rvm-prompt] )); then 18 | version="$(rvm-prompt)" 19 | elif (( $+commands[rbenv] )); then 20 | version="$(rbenv version-name)" 21 | elif (( $+commands[ruby] )); then 22 | version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" 23 | fi 24 | 25 | # Format version. 26 | if [[ -n "$version" ]]; then 27 | zstyle -s ':prezto:module:ruby:info:version' format 'version_format' 28 | zformat -f version_formatted "$version_format" "v:$version" 29 | ruby_info[version]="$version_formatted" 30 | fi 31 | 32 | -------------------------------------------------------------------------------- /modules/rsync/README.md: -------------------------------------------------------------------------------- 1 | Rsync 2 | ===== 3 | 4 | Defines [rsync][1] aliases. 5 | 6 | Mac OS X users are encouraged to use [Bombich's rsync][2], which has HFS+ 7 | enhancements. 8 | 9 | Aliases 10 | ------- 11 | 12 | - `rsync-copy` copies files and directories from *source* to *destination*. 13 | - `rsync-move` moves files and directories from *source* to *destination*. 14 | - `rsync-update` updates files and directories on *destination*. 15 | - `rsync-synchronize` synchronizes files and directories between *source* and 16 | *destination*. 17 | 18 | Authors 19 | ------- 20 | 21 | *The authors of this module should be contacted via the [issue tracker][3].* 22 | 23 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 24 | 25 | [1]: http://rsync.samba.org 26 | [2]: http://help.bombich.com/kb/overview/credits#opensource 27 | [3]: https://github.com/sorin-ionescu/prezto/issues 28 | 29 | -------------------------------------------------------------------------------- /modules/utility/functions/wdiff: -------------------------------------------------------------------------------- 1 | # 2 | # Highlights wdiff output. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | function wdiff { 9 | if zstyle -t ':prezto:module:utility:wdiff' color; then 10 | if (( $+commands[wdiff] )); then 11 | command wdiff \ 12 | --avoid-wraps \ 13 | --start-delete="$(print -n $FG[red])" \ 14 | --end-delete="$(print -n $FG[none])" \ 15 | --start-insert="$(print -n $FG[green])" \ 16 | --end-insert="$(print -n $FG[none])" \ 17 | "$@" \ 18 | | sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g' 19 | elif (( $+commands[git] )); then 20 | git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" 21 | else 22 | command wdiff "$@" 23 | fi 24 | else 25 | command wdiff "$@" 26 | fi 27 | } 28 | 29 | wdiff "$@" 30 | 31 | -------------------------------------------------------------------------------- /modules/git/functions/git-submodule-remove: -------------------------------------------------------------------------------- 1 | # 2 | # Removes a Git submodule. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | elif [[ "$PWD" != "$(git-root)" ]]; then 12 | print "$0: must be run from the root of the work tree" >&2 13 | return 1 14 | elif ! git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then 15 | print "$0: submodule not found: $1" >&2 16 | return 1 17 | fi 18 | 19 | git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &>/dev/null 20 | git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &>/dev/null 21 | git add .gitmodules 22 | 23 | git rm --cached -rf "${1}" 24 | rm -rf "${1}" 25 | rm -rf "$(git-dir)/modules/${1}" 26 | 27 | return 0 28 | 29 | -------------------------------------------------------------------------------- /modules/helper/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines helper functions. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Checks if a file can be autoloaded by trying to load it in a subshell. 9 | function is-autoloadable { 10 | ( unfunction $1 ; autoload -U +X $1 ) &> /dev/null 11 | } 12 | 13 | # Checks if a name is a command, function, or alias. 14 | function is-callable { 15 | (( $+commands[$1] )) || (( $+functions[$1] )) || (( $+aliases[$1] )) 16 | } 17 | 18 | # Checks a boolean variable for "true". 19 | # Case insensitive: "1", "y", "yes", "t", "true", "o", and "on". 20 | function is-true { 21 | [[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]] 22 | } 23 | 24 | # Prints the first non-empty string in the arguments array. 25 | function coalesce { 26 | for arg in $argv; do 27 | print "$arg" 28 | return 0 29 | done 30 | return 1 31 | } 32 | 33 | -------------------------------------------------------------------------------- /modules/emacs/README.md: -------------------------------------------------------------------------------- 1 | Emacs 2 | ===== 3 | 4 | Enables Emacs dependency management. 5 | 6 | Dependency management 7 | --------------------- 8 | 9 | [Carton][1] installs and manages Emacs packages for Emacs package development 10 | and Emacs configuration. 11 | 12 | This module prepends the Carton directory to the path variable to enable the 13 | execution of `carton`. 14 | 15 | Aliases 16 | ------- 17 | 18 | ### Carton 19 | 20 | - `cai` installs dependencies. 21 | - `cau` updates dependencies. 22 | - `caI` initializes the current directory for dependency management. 23 | - `cae` executes a command which correct dependencies. 24 | 25 | Authors 26 | ------- 27 | 28 | *The authors of this module should be contacted via the [issue tracker][2].* 29 | 30 | - [Sebastian Wiesner](https://github.com/lunaryorn) 31 | 32 | [1]: https://github.com/rejeep/carton 33 | [2]: https://github.com/sorin-ionescu/prezto/issues 34 | -------------------------------------------------------------------------------- /modules/yum/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines yum aliases. 3 | # 4 | # Authors: 5 | # Simon 6 | # Sorin Ionescu 7 | # 8 | 9 | # Return if requirements are not found. 10 | if (( ! $+commands[yum] )); then 11 | return 1 12 | fi 13 | 14 | # 15 | # Aliases 16 | # 17 | 18 | alias yumc='sudo yum clean all' # Cleans the cache. 19 | alias yumh='yum history' # Displays history. 20 | alias yumi='sudo yum install' # Installs package(s). 21 | alias yuml='yum list' # Lists packages. 22 | alias yumL='yum list installed' # Lists installed packages. 23 | alias yumq='yum info' # Displays package information. 24 | alias yumr='sudo yum remove' # Removes package(s). 25 | alias yums='yum search' # Searches for a package. 26 | alias yumu='sudo yum update' # Updates packages. 27 | alias yumU='sudo yum upgrade' # Upgrades packages. 28 | 29 | -------------------------------------------------------------------------------- /modules/rsync/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Rsync aliases. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[rsync] )); then 10 | return 1 11 | fi 12 | 13 | # 14 | # Aliases 15 | # 16 | 17 | _rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system' 18 | 19 | # Mac OS X and HFS+ Enhancements 20 | # http://help.bombich.com/kb/overview/credits#opensource 21 | if [[ "$OSTYPE" == darwin* ]] && grep -q 'file-flags' <(rsync --help 2>&1); then 22 | _rsync_cmd="${_rsync_cmd} --crtimes --acls --xattrs --fileflags --protect-decmpfs --force-change" 23 | fi 24 | 25 | alias rsync-copy="${_rsync_cmd}" 26 | alias rsync-move="${_rsync_cmd} --remove-source-files" 27 | alias rsync-update="${_rsync_cmd} --update" 28 | alias rsync-synchronize="${_rsync_cmd} --update --delete" 29 | 30 | unset _rsync_cmd 31 | 32 | -------------------------------------------------------------------------------- /modules/gnu-utility/README.md: -------------------------------------------------------------------------------- 1 | GNU Utility 2 | =========== 3 | 4 | Provides for the interactive use of GNU utilities on non-GNU systems. 5 | 6 | Installing GNU utilities on non-GNU systems in `$PATH` without a prefix, i.e. 7 | `ls` instead of `gls`, is not recommended since scripts that target other 8 | utilities will be broken. 9 | 10 | This module wraps GNU utilities in functions without a prefix for interactive 11 | use. 12 | 13 | This module must be loaded **before** the *utility* module. 14 | 15 | Settings 16 | -------- 17 | 18 | ### Prefix 19 | 20 | To use a different prefix, add the following to *zpreztorc*, and replace 'g' with 21 | the desired prefix: 22 | 23 | zstyle ':prezto:module:gnu-utility' prefix 'g' 24 | 25 | Authors 26 | ------- 27 | 28 | *The authors of this module should be contacted via the [issue tracker][1].* 29 | 30 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 31 | 32 | [1]: https://github.com/sorin-ionescu/prezto/issues 33 | 34 | -------------------------------------------------------------------------------- /modules/dpkg/functions/deb-history: -------------------------------------------------------------------------------- 1 | # 2 | # Displays dpkg history. 3 | # 4 | # Authors: 5 | # Peter Leung 6 | # Benjamin Boudreau 7 | # Sorin Ionescu 8 | # 9 | 10 | case "$1" in 11 | (install) 12 | zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) 13 | ;; 14 | (upgrade|remove) 15 | zgrep --no-filename "$1" $(ls -rt /var/log/dpkg*) 16 | ;; 17 | (rollback) 18 | zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) \ 19 | | grep "$2" -A10000000 \ 20 | | grep "$3" -B10000000 \ 21 | | awk '{print $4"="$5}' 22 | ;; 23 | (list) 24 | zcat $(ls -rt /var/log/dpkg*) 25 | ;; 26 | (*) 27 | cat >&2 < 9 | # 10 | 11 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 12 | return 1 13 | fi 14 | 15 | local state expl ret=1 16 | local -a submodules 17 | local submodule 18 | 19 | _arguments -C -s -S \ 20 | '1::args:->submodule' \ 21 | '2::args:->directory' && ret=0 22 | 23 | case "$state" in 24 | (submodule) 25 | while IFS=$'\n' read submodule; do 26 | submodules+=("$submodule") 27 | done < <( 28 | git config --file "$(git-root)/.gitmodules" --list \ 29 | | grep '.path=' \ 30 | | cut -d= -f2- 31 | ) 32 | 33 | _describe -t submodule 'submodules' submodules && ret=0 34 | ;; 35 | (directory) 36 | _wanted directories expl 'directory' _path_files -/ || _message 'directory' 37 | ;; 38 | esac 39 | 40 | return $ret 41 | 42 | -------------------------------------------------------------------------------- /modules/syntax-highlighting/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Integrates zsh-syntax-highlighting into Prezto. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if ! zstyle -t ':prezto:module:syntax-highlighting' color; then 10 | return 1 11 | fi 12 | 13 | # Source module files. 14 | source "${0:h}/external/zsh-syntax-highlighting.zsh" || return 1 15 | 16 | # Set highlighters. 17 | zstyle -a ':prezto:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS' 18 | if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then 19 | ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) 20 | fi 21 | 22 | # Set highlighting styles. 23 | typeset -A syntax_highlighting_styles 24 | zstyle -a ':prezto:module:syntax-highlighting' styles 'syntax_highlighting_styles' 25 | for syntax_highlighting_style in "${(k)syntax_highlighting_styles[@]}"; do 26 | ZSH_HIGHLIGHT_STYLES[$syntax_highlighting_style]="$syntax_highlighting_styles[$syntax_highlighting_style]" 27 | done 28 | unset syntax_highlighting_style{s,} 29 | 30 | -------------------------------------------------------------------------------- /modules/screen/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines GNU Screen aliases and provides for auto launching it at start-up. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # Georges Discry 7 | # 8 | 9 | # Return if requirements are not found. 10 | if (( ! $+commands[screen] )); then 11 | return 1 12 | fi 13 | 14 | # 15 | # Auto Start 16 | # 17 | 18 | if [[ -z "$STY" && -z "$EMACS" && -z "$VIM" ]] && ( \ 19 | ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) || 20 | ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) \ 21 | ); then 22 | session="$( 23 | screen -list 2> /dev/null \ 24 | | sed '1d;$d' \ 25 | | awk '{print $1}' \ 26 | | head -1)" 27 | 28 | if [[ -n "$session" ]]; then 29 | exec screen -x "$session" 30 | else 31 | exec screen -a -A -U -D -R -m "$SHELL" -l 32 | fi 33 | fi 34 | 35 | # 36 | # Aliases 37 | # 38 | 39 | alias scr='screen' 40 | alias scrl='screen -list' 41 | alias scrn='screen -U -S' 42 | alias scrr='screen -a -A -U -D -R' 43 | 44 | -------------------------------------------------------------------------------- /modules/rails/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Ruby on Rails aliases. 3 | # 4 | # Authors: 5 | # Robby Russell 6 | # Jake Bell 7 | # Sorin Ionescu 8 | # 9 | 10 | # Load dependencies. 11 | pmodload 'ruby' 12 | 13 | # Return if requirements are not found. 14 | if (( ! $+commands[bundle] )); then 15 | return 1 16 | fi 17 | 18 | # 19 | # Aliases 20 | # 21 | 22 | alias ror='bundle exec rails' 23 | alias rorc='bundle exec rails console' 24 | alias rordc='bundle exec rails dbconsole' 25 | alias rordm='bundle exec rake db:migrate' 26 | alias rordM='bundle exec rake db:migrate db:test:clone' 27 | alias rordr='bundle exec rake db:rollback' 28 | alias rorg='bundle exec rails generate' 29 | alias rorl='tail -f "$(ruby-app-root)/log/development.log"' 30 | alias rorlc='bundle exec rake log:clear' 31 | alias rorp='bundle exec rails plugin' 32 | alias rorr='bundle exec rails runner' 33 | alias rors='bundle exec rails server' 34 | alias rorsd='bundle exec rails server --debugger' 35 | alias rorx='bundle exec rails destroy' 36 | 37 | -------------------------------------------------------------------------------- /modules/helper/functions/add-zsh-trap: -------------------------------------------------------------------------------- 1 | # 2 | # Provides for trapping UNIX signals and calling callback functions when a trap 3 | # is triggered. 4 | # 5 | # Authors: 6 | # Sorin Ionescu 7 | # 8 | 9 | # Adds a function name to a list to be called when a trap is triggered. 10 | function add-zsh-trap { 11 | if (( $# < 2 )); then 12 | print "usage: $0 type function" >&2 13 | return 1 14 | fi 15 | 16 | if [[ -z "$signals[(r)$1]" ]]; then 17 | print "$0: unknown signal: $1" >&2 18 | return 1 19 | fi 20 | 21 | local trap_functions="TRAP${1}_FUNCTIONS" 22 | if (( ! ${(P)+trap_functions} )); then 23 | typeset -gaU "$trap_functions" 24 | fi 25 | eval "$trap_functions+="$2"" 26 | 27 | if (( ! $+functions[TRAP${1}] )); then 28 | eval " 29 | function TRAP${1} { 30 | for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do 31 | if (( \$+functions[\$trap_function] )); then 32 | \"\$trap_function\" \"\$1\" 33 | fi 34 | done 35 | return \$(( 128 + \$1 )) 36 | } 37 | " 38 | fi 39 | } 40 | 41 | add-zsh-trap "$@" 42 | 43 | -------------------------------------------------------------------------------- /modules/directory/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets directory options and defines directory aliases. 3 | # 4 | # Authors: 5 | # James Cox 6 | # Sorin Ionescu 7 | # 8 | 9 | # 10 | # Options 11 | # 12 | 13 | setopt AUTO_CD # Auto changes to a directory without typing cd. 14 | setopt AUTO_PUSHD # Push the old directory onto the stack on cd. 15 | setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. 16 | setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. 17 | setopt PUSHD_TO_HOME # Push to home directory when no argument is given. 18 | setopt CDABLE_VARS # Change directory to a path stored in a variable. 19 | setopt AUTO_NAME_DIRS # Auto add variable-stored paths to ~ list. 20 | setopt MULTIOS # Write to multiple descriptors. 21 | setopt EXTENDED_GLOB # Use extended globbing syntax. 22 | unsetopt CLOBBER # Do not overwrite existing files with > and >>. 23 | # Use >! and >>! to bypass. 24 | 25 | # 26 | # Aliases 27 | # 28 | 29 | alias d='dirs -v' 30 | for index ({1..9}) alias "$index"="cd +${index}"; unset index 31 | 32 | -------------------------------------------------------------------------------- /modules/wakeonlan/README.md: -------------------------------------------------------------------------------- 1 | Wake-on-LAN 2 | =========== 3 | 4 | This module provides a wrapper around the [wakeonlan][1] tool. 5 | 6 | Usage 7 | ----- 8 | 9 | To use this wrapper, create the *~/.wakeonlan* directory, and place in it one 10 | file for each device you would like to be able to wake. Give the file a name 11 | that describes the device, such as its hostname. 12 | 13 | Each file should contain a line with the MAC address of the target device and 14 | the network broadcast address. For instance, there might be a file 15 | *~/.wakeonlan/leto* with the following contents: 16 | 17 | 00:11:22:33:44:55:66 192.168.0.255 18 | 19 | To wake that device, use the following command: 20 | 21 | wake leto 22 | 23 | For more information on the configuration file format, read the 24 | [wakeonlan man page][2]. 25 | 26 | Authors 27 | ------- 28 | 29 | *The authors of this module should be contacted via [issue tracker][3].* 30 | 31 | - [Paul Dann](https://github.com/giddie) 32 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 33 | 34 | [1]: http://gsd.di.uminho.pt/jpo/software/wakeonlan/ 35 | [2]: http://man.cx/wakeonlan 36 | [3]: https://github.com/sorin-ionescu/prezto/issues 37 | 38 | -------------------------------------------------------------------------------- /modules/rails/README.md: -------------------------------------------------------------------------------- 1 | Ruby on Rails 2 | ============= 3 | 4 | Defines [Ruby on Rails][1] aliases. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `ror` is short for `rails`. 10 | - `rorc` starts the Rails console. 11 | - `rordc` starts the Rails console connected to the database. 12 | - `rordm` migrates the database. 13 | - `rordM` migrates the database and recreates the test database. 14 | - `rordr` rolls the database schema back to the previous version. 15 | - `rorg` generates new code. 16 | - `rorl` displays the log. 17 | - `rorlc` truncates logs to zero bytes. 18 | - `rorp` installs a plugin. 19 | - `rorr` runs code in the application environment. 20 | - `rors` starts the Rails server. 21 | - `rorsd` starts the Rails server with the debugger. 22 | - `rorx` destroys newly generated code. 23 | 24 | Authors 25 | ------- 26 | 27 | *The authors of this module should be contacted via the [issue tracker][2].* 28 | 29 | - [Robby Russell](https://github.com/robbyrussell) 30 | - [Jake Bell](https://github.com/theunraveler) 31 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 32 | 33 | [1]: http://rubyonrails.org 34 | [2]: https://github.com/sorin-ionescu/prezto/issues 35 | 36 | -------------------------------------------------------------------------------- /modules/osx/functions/tab: -------------------------------------------------------------------------------- 1 | # 2 | # Opens a new Terminal.app/iTerm.app tab in the current directory. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local command="cd \\\"$PWD\\\"" 9 | (( $# > 0 )) && command="${command}; $*" 10 | 11 | the_app=$( 12 | osascript 2>/dev/null </dev/null </dev/null <tab. 25 | 26 | Authors 27 | ------- 28 | 29 | *The authors of this module should be contacted via the [issue tracker][5].* 30 | 31 | - [Wei Dai](https://github.com/clvv) 32 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 33 | 34 | [1]: https://github.com/clvv/fasd 35 | [2]: https://github.com/joelthelion/autojump 36 | [3]: https://github.com/rupa/z 37 | [4]: https://github.com/rupa/v 38 | [5]: https://github.com/sorin-ionescu/prezto/issues 39 | 40 | -------------------------------------------------------------------------------- /modules/perl/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Enables local Perl module installation on Mac OS X and defines aliases. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[perl] )); then 10 | return 1 11 | fi 12 | 13 | # 14 | # Local Module Installation 15 | # 16 | 17 | if [[ "$OSTYPE" == darwin* ]]; then 18 | # Perl is slow; cache its output. 19 | cache_file="${0:h}/cache.zsh" 20 | perl_path="$HOME/Library/Perl/5.12" 21 | 22 | if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then 23 | if [[ ! -s "$cache_file" ]]; then 24 | perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file" 25 | fi 26 | 27 | source "$cache_file" 28 | fi 29 | 30 | unset perl_path 31 | unset cache_file 32 | fi 33 | 34 | # 35 | # Aliases 36 | # 37 | 38 | # General 39 | alias pl='perl' 40 | alias pld='perldoc' 41 | alias ple='perl -wlne' 42 | 43 | # Perlbrew 44 | alias plb='perlbrew' 45 | alias plba='perlbrew available' 46 | alias plbi='perlbrew install' 47 | alias plbl='perlbrew list' 48 | alias plbo='perlbrew off' 49 | alias plbO='perlbrew switch-off' 50 | alias plbs='perlbrew switch' 51 | alias plbu='perlbrew use' 52 | alias plbx='perlbrew uninstall' 53 | 54 | -------------------------------------------------------------------------------- /modules/tmux/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines tmux aliases and provides for auto launching it at start-up. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # Colin Hebert 7 | # Georges Discry 8 | # Xavier Cambar 9 | # 10 | 11 | # Return if requirements are not found. 12 | if (( ! $+commands[tmux] )); then 13 | return 1 14 | fi 15 | 16 | # 17 | # Auto Start 18 | # 19 | 20 | if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ 21 | ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || 22 | ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ 23 | ); then 24 | tmux start-server 25 | 26 | # Create a 'prezto' session if no session has been defined in tmux.conf. 27 | if ! tmux has-session 2> /dev/null; then 28 | tmux_session='prezto' 29 | tmux \ 30 | new-session -d -s "$tmux_session" \; \ 31 | set-option -t "$tmux_session" destroy-unattached off &> /dev/null 32 | fi 33 | 34 | # Attach to the 'prezto' session or to the last session used. 35 | exec tmux attach-session 36 | fi 37 | 38 | # 39 | # Aliases 40 | # 41 | 42 | alias tmuxa='tmux attach-session' 43 | alias tmuxl='tmux list-sessions' 44 | -------------------------------------------------------------------------------- /modules/utility/functions/prep: -------------------------------------------------------------------------------- 1 | # 2 | # Provides a grep-like pattern search. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local usage pattern modifiers invert 9 | 10 | usage="$( 11 | cat <&2 32 | print "$usage" >&2 33 | return 1 34 | ;; 35 | ([?]) 36 | print "$0: unknown option: $OPTARG" >&2 37 | print "$usage" >&2 38 | return 1 39 | ;; 40 | esac 41 | done 42 | shift $(( $OPTIND - 1 )) 43 | 44 | if (( $# < 1 )); then 45 | print "$usage" >&2 46 | return 1 47 | fi 48 | 49 | pattern="$1" 50 | shift 51 | 52 | perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@" 53 | 54 | -------------------------------------------------------------------------------- /modules/fasd/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Maintains a frequently used file and directory list for fast access. 3 | # 4 | # Authors: 5 | # Wei Dai 6 | # Sorin Ionescu 7 | # 8 | 9 | # Load dependencies. 10 | pmodload 'editor' 11 | 12 | # Return if requirements are not found. 13 | if (( ! $+commands[fasd] )); then 14 | return 1 15 | fi 16 | 17 | # 18 | # Initialization 19 | # 20 | 21 | cache_file="${0:h}/cache.zsh" 22 | if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then 23 | # Set the base init arguments. 24 | init_args=(zsh-hook) 25 | 26 | # Set fasd completion init arguments, if applicable. 27 | if zstyle -t ':prezto:module:completion' loaded; then 28 | init_args+=(zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install) 29 | fi 30 | 31 | # Cache init code. 32 | fasd --init "$init_args[@]" >! "$cache_file" 2> /dev/null 33 | fi 34 | 35 | source "$cache_file" 36 | 37 | unset cache_file init_args 38 | 39 | function fasd_cd { 40 | local fasd_ret="$(fasd -d "$@")" 41 | if [[ -d "$fasd_ret" ]]; then 42 | cd "$fasd_ret" 43 | else 44 | print "$fasd_ret" 45 | fi 46 | } 47 | 48 | # 49 | # Aliases 50 | # 51 | 52 | # Changes the current working directory interactively. 53 | alias j='fasd_cd -i' 54 | 55 | -------------------------------------------------------------------------------- /modules/gpg/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Provides for an easier use of GPG by setting up gpg-agent. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if (( ! $+commands[gpg-agent] )); then 10 | return 1 11 | fi 12 | 13 | # Set the default paths to gpg-agent files. 14 | _gpg_agent_conf="$HOME/.gnupg/gpg-agent.conf" 15 | _gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env" 16 | 17 | # Start gpg-agent if not started. 18 | if ! ps -U "$USER" -o ucomm | grep -q gpg-agent; then 19 | eval "$(gpg-agent --daemon | tee "$_gpg_agent_env")" 20 | else 21 | # Export environment variables. 22 | source "$_gpg_agent_env" 2> /dev/null 23 | fi 24 | 25 | # Inform gpg-agent of the current TTY for user prompts. 26 | export GPG_TTY="$(tty)" 27 | 28 | # Integrate with the SSH module. 29 | if grep 'enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then 30 | # Override the ssh-agent environment file default path. 31 | _ssh_agent_env="$_gpg_agent_env" 32 | 33 | # Load the SSH module for additional processing. 34 | pmodload 'ssh' 35 | fi 36 | 37 | # Clean up. 38 | unset _gpg_agent_{conf,env} 39 | 40 | # Disable GUI prompts inside SSH. 41 | if [[ -n "$SSH_CONNECTION" ]]; then 42 | export PINENTRY_USER_DATA='USE_CURSES=1' 43 | fi 44 | 45 | -------------------------------------------------------------------------------- /modules/osx/README.md: -------------------------------------------------------------------------------- 1 | OSX 2 | === 3 | 4 | Defines [Mac OS X][1] aliases and functions. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `cdf` changes the current working director to the current _Finder_ 10 | directory. 11 | - `pushdf` pushes the current working directory onto the directory queue and 12 | changes the current working director to the current _Finder_ directory. 13 | 14 | Functions 15 | --------- 16 | 17 | - `mand` opens _man_ pages in [_Dash.app_][2]. 18 | - `manp` opens _man_ pages in _Preview.app_. 19 | - `pfd` prints the current _Finder_ directory. 20 | - `pfs` prints the current _Finder_ selection. 21 | - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). 22 | - `ql` previews files in Quick Look. 23 | - `osx-rm-dir-metadata` deletes .DS\_Store, \_\_MACOSX cruft. 24 | - `osx-ls-download-history` displays the Mac OS X download history. 25 | - `osx-rm-download-history` deletes the Mac OS X download history. 26 | 27 | Authors 28 | ------- 29 | 30 | *The authors of this module should be contacted via the [issue tracker][4].* 31 | 32 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 33 | 34 | [1]: http://www.apple.com/macosx/ 35 | [2]: http://kapeli.com/dash 36 | [3]: http://www.iterm2.com/ 37 | [4]: https://github.com/sorin-ionescu/prezto/issues 38 | -------------------------------------------------------------------------------- /modules/dpkg/README.md: -------------------------------------------------------------------------------- 1 | Dpkg 2 | ==== 3 | 4 | Defines [dpkg][1] aliases and functions. 5 | 6 | Aliases 7 | ------- 8 | 9 | - `debc` cleans the cache. 10 | - `debf` displays a file's package. 11 | - `debi` installs packages from repositories. 12 | - `debI` installs packages from files. 13 | - `debq` displays package information. 14 | - `debu` updates the package lists. 15 | - `debU` upgrades outdated packages. 16 | - `debx` removes packages. 17 | - `debX` removes packages, their configuration, and unneeded dependencies. 18 | - `debs` searches for packages. 19 | - `deb-build` creates a basic deb package. 20 | - `deb-kclean` removes all kernel images and headers, except for the ones in 21 | use. 22 | 23 | Functions 24 | --------- 25 | 26 | - `deb-clone` generates a script that can be used to duplicate a dpkg-based 27 | system. 28 | - `deb-history` displays dpkg history. 29 | - `deb-kbuild` makes a dpkg Linux kernel package. 30 | 31 | Authors 32 | ------- 33 | 34 | *The authors of this module should be contacted via the [issue tracker][2].* 35 | 36 | - [Daniel Bolton](https://github.com/dbb) 37 | - [Benjamin Boudreau](https://github.com/dreur) 38 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 39 | 40 | [1]: http://wiki.debian.org/Teams/Dpkg 41 | [2]: https://github.com/sorin-ionescu/prezto/issues 42 | 43 | -------------------------------------------------------------------------------- /modules/directory/README.md: -------------------------------------------------------------------------------- 1 | Directory 2 | ========= 3 | 4 | Sets directory options and defines directory aliases. 5 | 6 | Options 7 | ------- 8 | 9 | - `AUTO_CD` auto changes to a directory without typing `cd`. 10 | - `AUTO_PUSHD` pushes the old directory onto the stack on `cd`. 11 | - `PUSHD_IGNORE_DUPS` does not store duplicates in the stack. 12 | - `PUSHD_SILENT` does not print the directory stack after `pushd` or `popd`. 13 | - `PUSHD_TO_HOME` pushes to the home directory when no argument is given. 14 | - `CDABLE_VARS` changes directory to a path stored in a variable. 15 | - `AUTO_NAME_DIRS` auto adds variable-stored paths to `~` list. 16 | - `MULTIOS` writes to multiple descriptors. 17 | - `EXTENDED_GLOB` uses extended globbing syntax. 18 | - `CLOBBER` does not overwrite existing files with `>` and `>>`. Use `>!` and 19 | `>>!` to bypass. 20 | 21 | Aliases 22 | ------- 23 | 24 | - `d` prints the contents of the directory stack. 25 | - `1 ... 9` changes the directory to the **n** previous one. 26 | 27 | Authors 28 | ------- 29 | 30 | *The authors of this module should be contacted via the [issue tracker][1].* 31 | 32 | - [James Cox](https://github.com/imajes) 33 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 34 | 35 | [1]: https://github.com/sorin-ionescu/prezto/issues 36 | 37 | -------------------------------------------------------------------------------- /modules/utility/functions/psub: -------------------------------------------------------------------------------- 1 | # 2 | # Provides a sed-like pattern substitution. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local usage pattern replacement modifiers 9 | 10 | usage="$( 11 | cat <&2 32 | print "$usage" >&2 33 | return 1 34 | ;; 35 | ([?]) 36 | print "$0: unknown option: $OPTARG" >&2 37 | print "$usage" >&2 38 | return 1 39 | ;; 40 | esac 41 | done 42 | shift $(( $OPTIND - 1 )) 43 | 44 | if (( $# < 2 )); then 45 | print "$usage" >&2 46 | return 1 47 | fi 48 | 49 | pattern="$1" 50 | replacement="$2" 51 | repeat 2 shift 52 | 53 | perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@" 54 | 55 | -------------------------------------------------------------------------------- /modules/git/functions/_git-hub-browse: -------------------------------------------------------------------------------- 1 | #compdef git-hub-browse 2 | #autoload 3 | 4 | # 5 | # Completes git-hub-browse. 6 | # 7 | # Authors: 8 | # Sorin Ionescu 9 | # 10 | 11 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 12 | return 1 13 | fi 14 | 15 | local state expl remotes remote branches_or_tags branches tags files ret=1 16 | 17 | _arguments -C -s -S \ 18 | '1::args:->remote' \ 19 | '2::args:->branch-or-tag' \ 20 | '3::args:->file' && ret=0 21 | 22 | case "$state" in 23 | (remote) 24 | remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) 25 | 26 | _describe -t branch 'remotes' remotes && ret=0 27 | ;; 28 | (branch-or-tag) 29 | remote="$words[(($CURRENT - 1))]" 30 | 31 | branches_or_tags=($( 32 | git ls-remote --heads --tags "$remote" 2>/dev/null | cut -f2 33 | )) 34 | 35 | branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/}) 36 | tags=(${${(M)branches_or_tags[@]##refs/tags/?##}##refs/tags/}) 37 | 38 | _describe -t branch 'branches' branches && ret=0 39 | _describe -t tag 'tags' tags && ret=0 40 | ;; 41 | (file) 42 | files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"}) 43 | _wanted file expl 'file' _multi_parts - / files && ret=0 44 | ;; 45 | esac 46 | 47 | return $ret 48 | 49 | -------------------------------------------------------------------------------- /modules/node/README.md: -------------------------------------------------------------------------------- 1 | Node.js 2 | ======= 3 | 4 | Provides utility functions for [Node.js][1], loads the Node Version Manager, and 5 | enables [npm][2] completion. 6 | 7 | nvm 8 | --- 9 | 10 | [nvm][5] allows for managing multiple, isolated Node.js installations in the 11 | home directory. 12 | 13 | Functions 14 | --------- 15 | 16 | - `node-doc` opens the Node.js online [API documentation][3] in the default 17 | browser. 18 | - `node-info` exposes information about the Node.js environment via the 19 | `$node_info` associative array. 20 | 21 | Theming 22 | ------- 23 | 24 | To display the version number of the current Node.js version, define the 25 | following style inside the `prompt_name_setup` function. 26 | 27 | # %v - Node.js version. 28 | zstyle ':prezto:module:node:info:version' format 'version:%v' 29 | 30 | Then add `$node_info[version]` to either `$PROMPT` or `$RPROMPT` and call 31 | `node-info` in `prompt_name_preexec` hook function. 32 | 33 | Authors 34 | ------- 35 | 36 | *The authors of this module should be contacted via the [issue tracker][4].* 37 | 38 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 39 | - [Zeh Rizzatti](https://github.com/zehrizzatti) 40 | 41 | [1]: http://nodejs.org 42 | [2]: http://npmjs.org 43 | [3]: http://nodejs.org/api 44 | [4]: https://github.com/sorin-ionescu/prezto/issues 45 | [5]: https://github.com/creationix/nvm 46 | 47 | -------------------------------------------------------------------------------- /modules/terminal/README.md: -------------------------------------------------------------------------------- 1 | Terminal 2 | ======== 3 | 4 | Sets terminal window and tab titles. 5 | 6 | Settings 7 | -------- 8 | 9 | ### Auto-Title 10 | 11 | To auto set the terminal window and tab titles with the current command or 12 | directory, add the following to *zpreztorc*: 13 | 14 | zstyle ':prezto:module:terminal' auto-title 'yes' 15 | 16 | Auto titling is disabled inside terminal multiplexers, except inside dvtm, since 17 | it interferes with window names defined in configuration files and profile 18 | managers. 19 | 20 | To format terminal window and tab titles, add the following to *zpreztorc*: 21 | 22 | zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' 23 | zstyle ':prezto:module:terminal:tab-title' format '%m: %s' 24 | 25 | `%s` will be replaced with the current working directory path or the currently 26 | executing program name. 27 | 28 | For a list of sequences, see [Expansion of Prompt Sequences][1]. 29 | 30 | Functions 31 | --------- 32 | 33 | - `set-tab-title` sets the terminal tab title. 34 | - `set-window-title` sets the terminal or terminal multiplexer window title. 35 | 36 | Authors 37 | ------- 38 | 39 | *The authors of this module should be contacted via the [issue tracker][2].* 40 | 41 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 42 | 43 | [1]: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Expansion-of-Prompt-Sequences 44 | [2]: https://github.com/sorin-ionescu/prezto/issues 45 | 46 | -------------------------------------------------------------------------------- /modules/archive/functions/lsarchive: -------------------------------------------------------------------------------- 1 | # 2 | # Lists the contents of archives. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local verbose 9 | 10 | if (( $# == 0 )); then 11 | cat >&2 <. 18 | EOF 19 | fi 20 | 21 | if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then 22 | verbose=0 23 | shift 24 | fi 25 | 26 | while (( $# > 0 )); do 27 | if [[ ! -s "$1" ]]; then 28 | print "$0: file not valid: $1" >&2 29 | shift 30 | continue 31 | fi 32 | 33 | case "$1" in 34 | (*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;; 35 | (*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;; 36 | (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ 37 | && tar --xz -t${verbose:+v}f "$1" \ 38 | || xzcat "$1" | tar t${verbose:+v}f - ;; 39 | (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ 40 | && tar --lzma -t${verbose:+v}f "$1" \ 41 | || lzcat "$1" | tar x${verbose:+v}f - ;; 42 | (*.tar) tar t${verbose:+v}f "$1" ;; 43 | (*.zip) unzip -l${verbose:+v} "$1" ;; 44 | (*.rar) unrar &> /dev/null \ 45 | && unrar ${${verbose:+v}:-l} "$1" \ 46 | || rar ${${verbose:+v}:-l} "$1" ;; 47 | (*.7z) 7za l "$1" ;; 48 | (*) 49 | print "$0: cannot list: $1" >&2 50 | success=1 51 | ;; 52 | esac 53 | 54 | shift 55 | done 56 | 57 | -------------------------------------------------------------------------------- /runcoms/zprofile: -------------------------------------------------------------------------------- 1 | # 2 | # Executes commands at login pre-zshrc. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # Browser 10 | # 11 | 12 | if [[ "$OSTYPE" == darwin* ]]; then 13 | export BROWSER='open' 14 | fi 15 | 16 | # 17 | # Editors 18 | # 19 | 20 | export EDITOR='nano' 21 | export VISUAL='nano' 22 | export PAGER='less' 23 | 24 | # 25 | # Language 26 | # 27 | 28 | if [[ -z "$LANG" ]]; then 29 | export LANG='en_US.UTF-8' 30 | fi 31 | 32 | # 33 | # Paths 34 | # 35 | 36 | # Ensure path arrays do not contain duplicates. 37 | typeset -gU cdpath fpath mailpath path 38 | 39 | # Set the the list of directories that cd searches. 40 | # cdpath=( 41 | # $cdpath 42 | # ) 43 | 44 | # Set the list of directories that Zsh searches for programs. 45 | path=( 46 | /usr/local/{bin,sbin} 47 | $path 48 | ) 49 | 50 | # 51 | # Less 52 | # 53 | 54 | # Set the default Less options. 55 | # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). 56 | # Remove -X and -F (exit if the content fits on one screen) to enable it. 57 | export LESS='-F -g -i -M -R -S -w -X -z-4' 58 | 59 | # Set the Less input preprocessor. 60 | if (( $+commands[lesspipe.sh] )); then 61 | export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' 62 | fi 63 | 64 | # 65 | # Temporary Files 66 | # 67 | 68 | if [[ ! -d "$TMPDIR" ]]; then 69 | export TMPDIR="/tmp/$USER" 70 | mkdir -p -m 700 "$TMPDIR" 71 | fi 72 | 73 | TMPPREFIX="${TMPDIR%/}/zsh" 74 | if [[ ! -d "$TMPPREFIX" ]]; then 75 | mkdir -p "$TMPPREFIX" 76 | fi 77 | 78 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_minimal_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A monochrome theme that displays basic information. 3 | # 4 | # Authors: 5 | # Brian Tse 6 | # Sorin Ionescu 7 | # 8 | # Screenshots: 9 | # http://i.imgur.com/zLZNK.png 10 | # 11 | 12 | function +vi-git-status() { 13 | # Check for untracked files or updated submodules since vcs_info does not. 14 | if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then 15 | hook_com[unstaged]='%F{red}●%f' 16 | fi 17 | } 18 | 19 | function prompt_minimal_precmd { 20 | vcs_info 21 | } 22 | 23 | function prompt_minimal_setup { 24 | setopt LOCAL_OPTIONS 25 | unsetopt XTRACE KSH_ARRAYS 26 | prompt_opts=(cr percent subst) 27 | 28 | # Load required functions. 29 | autoload -Uz add-zsh-hook 30 | autoload -Uz vcs_info 31 | 32 | # Add hook for calling vcs_info before each command. 33 | add-zsh-hook precmd prompt_minimal_precmd 34 | 35 | # Set vcs_info parameters. 36 | zstyle ':vcs_info:*' enable bzr git hg svn 37 | zstyle ':vcs_info:*' check-for-changes true 38 | zstyle ':vcs_info:*' stagedstr '%F{green}●%f' 39 | zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f' 40 | zstyle ':vcs_info:*' formats ' - [%b%c%u]' 41 | zstyle ':vcs_info:*' actionformats " - [%b%c%u|%F{cyan}%a%f]" 42 | zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b|%F{cyan}%r%f' 43 | zstyle ':vcs_info:git*+set-message:*' hooks git-status 44 | 45 | # Define prompts. 46 | PROMPT='%2~${vcs_info_msg_0_} » ' 47 | RPROMPT='' 48 | } 49 | 50 | prompt_minimal_setup "$@" 51 | 52 | -------------------------------------------------------------------------------- /modules/python/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Enables local Python package installation. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # Sebastian Wiesner 7 | # 8 | 9 | # Load manually installed pyenv into the shell session. 10 | if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then 11 | path=("$HOME/.pyenv/bin" $path) 12 | eval "$(pyenv init -)" 13 | 14 | # Load package manager installed pyenv into the shell session. 15 | elif (( $+commands[pyenv] )); then 16 | eval "$(pyenv init -)" 17 | 18 | # Prepend PEP 370 per user site packages directory, which defaults to 19 | # ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. The 20 | # path can be overridden using PYTHONUSERBASE. 21 | else 22 | if [[ -n "$PYTHONUSERBASE" ]]; then 23 | path=($PYTHONUSERBASE/bin $path) 24 | elif [[ "$OSTYPE" == darwin* ]]; then 25 | path=($HOME/Library/Python/*/bin(N) $path) 26 | else 27 | # This is subject to change. 28 | path=($HOME/.local/bin $path) 29 | fi 30 | fi 31 | 32 | # Return if requirements are not found. 33 | if (( ! $+commands[python] && ! $+commands[pyenv] )); then 34 | return 1 35 | fi 36 | 37 | # Load virtualenvwrapper into the shell session. 38 | if (( $+commands[virtualenvwrapper_lazy.sh] )); then 39 | # Set the directory where virtual environments are stored. 40 | export WORKON_HOME="$HOME/.virtualenvs" 41 | 42 | # Disable the virtualenv prompt. 43 | VIRTUAL_ENV_DISABLE_PROMPT=1 44 | 45 | source "$commands[virtualenvwrapper_lazy.sh]" 46 | fi 47 | 48 | # 49 | # Aliases 50 | # 51 | 52 | alias py='python' 53 | 54 | -------------------------------------------------------------------------------- /modules/git/functions/git-hub-browse: -------------------------------------------------------------------------------- 1 | # 2 | # Opens a GitHub repository in the default browser. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then 9 | print "$0: not a repository work tree: $PWD" >&2 10 | return 1 11 | fi 12 | 13 | local remotes remote references reference file url 14 | 15 | remote="${1:-origin}" 16 | remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) 17 | 18 | if (( $remotes[(i)$remote] == $#remotes + 1 )); then 19 | print "$0: remote not found: $remote" >&2 20 | return 1 21 | fi 22 | 23 | url=$( 24 | git config --get "remote.${remote}.url" \ 25 | | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" 26 | ) 27 | 28 | reference="${${2:-$(git-branch-current)}:-HEAD}" 29 | references=( 30 | HEAD 31 | ${$(git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/} 32 | ) 33 | 34 | if (( $references[(i)$reference] == $#references + 1 )); then 35 | print "$0: branch or tag not found: $reference" >&2 36 | return 1 37 | fi 38 | 39 | if [[ "$reference" == 'HEAD' ]]; then 40 | reference="$(git rev-parse HEAD 2>/dev/null)" 41 | fi 42 | 43 | file="$3" 44 | 45 | if [[ -n "$url" ]]; then 46 | url="${url}/tree/${reference}/${file}" 47 | 48 | if (( $+commands[$BROWSER] )); then 49 | "$BROWSER" "$url" 50 | return 0 51 | else 52 | print "$0: browser not set or set to a non-existent browser" >&2 53 | return 1 54 | fi 55 | else 56 | print "$0: not a Git repository or remote not set" >&2 57 | return 1 58 | fi 59 | 60 | -------------------------------------------------------------------------------- /modules/ssh/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Provides for an easier use of SSH by setting up ssh-agent. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then 10 | return 1 11 | fi 12 | 13 | # Set the path to the SSH directory. 14 | _ssh_dir="$HOME/.ssh" 15 | 16 | # Set the path to the environment file if not set by another module. 17 | _ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env}" 18 | 19 | # Set the path to the persistent authentication socket. 20 | _ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock" 21 | 22 | # Start ssh-agent if not started. 23 | if [[ ! -S "$SSH_AUTH_SOCK" ]]; then 24 | # Export environment variables. 25 | source "$_ssh_agent_env" 2> /dev/null 26 | 27 | # Start ssh-agent if not started. 28 | if ! ps -U "$USER" -o pid,ucomm | grep -q "${SSH_AGENT_PID} ssh-agent"; then 29 | eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" 30 | fi 31 | fi 32 | 33 | # Create a persistent SSH authentication socket. 34 | if [[ -S "$SSH_AUTH_SOCK" && "$SSH_AUTH_SOCK" != "$_ssh_agent_sock" ]]; then 35 | ln -sf "$SSH_AUTH_SOCK" "$_ssh_agent_sock" 36 | export SSH_AUTH_SOCK="$_ssh_agent_sock" 37 | fi 38 | 39 | # Load identities. 40 | if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then 41 | zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' 42 | if (( ${#_ssh_identities} > 0 )); then 43 | ssh-add "$_ssh_dir/${^_ssh_identities[@]}" 2> /dev/null 44 | else 45 | ssh-add 2> /dev/null 46 | fi 47 | fi 48 | 49 | # Clean up. 50 | unset _ssh_{dir,identities} _ssh_agent_{env,sock} 51 | 52 | -------------------------------------------------------------------------------- /modules/dpkg/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines dpkg aliases. 3 | # 4 | # Authors: 5 | # Daniel Bolton 6 | # Benjamin Boudreau 7 | # Sorin Ionescu 8 | # 9 | 10 | # Return if requirements are not found. 11 | if (( ! $+commands[dpkg] && ! $+commands[apt-get] )); then 12 | return 1 13 | fi 14 | 15 | # 16 | # Aliases 17 | # 18 | 19 | # Cleans the cache. 20 | alias debc='sudo apt-get clean && sudo apt-get autoclean' 21 | 22 | # Displays a file's package. 23 | alias debf='apt-file search --regexp' 24 | 25 | # Installs packages from repositories. 26 | alias debi='sudo apt-get install' 27 | 28 | # Installs packages from files. 29 | alias debI='sudo dpkg -i' 30 | 31 | # Displays package information. 32 | alias debq='apt-cache show' 33 | 34 | # Updates the package lists. 35 | alias debu='sudo apt-get update' 36 | 37 | # Upgrades outdated packages. 38 | alias debU='sudo apt-get update && sudo apt-get dist-upgrade' 39 | 40 | # Removes packages. 41 | alias debx='sudo apt-get remove' 42 | 43 | # Removes packages, their configuration, and unneeded dependencies. 44 | alias debX='sudo apt-get remove --purge && sudo apt-get autoremove --purge' 45 | 46 | # Searches for packages. 47 | if (( $+commands[aptitude] )); then 48 | alias debs='aptitude -F "* %p -> %d \n(%v/%V)" --no-gui --disable-columns search' 49 | else 50 | alias debs='apt-cache search' 51 | fi 52 | 53 | # Creates a basic deb package. 54 | alias deb-build='time dpkg-buildpackage -rfakeroot -us -uc' 55 | 56 | # Removes all kernel images and headers, except for the ones in use. 57 | alias deb-kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))"' 58 | 59 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ------------ 3 | 4 | This project would not exist without all of its users and [contributors][1]. 5 | 6 | If you have ideas on how to make the configuration easier to maintain or 7 | improve its performance, do not hesitate to fork and send pull requests. 8 | 9 | ### Issue Reporting 10 | 11 | - Check that the issue has not already been reported. 12 | - Check that the issue has not already been fixed in the latest code. 13 | - Open an issue with a clear title and description in grammatically correct, 14 | complete sentences. 15 | 16 | ### Pull Request 17 | 18 | - Read [how to properly contribute to open source projects on GitHub][2]. 19 | - Use a topic branch to easily amend a pull request later, if necessary. 20 | - Write [good commit messages][3]. 21 | - Squash commits on the topic branch before opening a pull request. 22 | - Use the same coding style and spacing. 23 | - Open a [pull request][4] that relates to but one subject with a clear 24 | title and description in grammatically correct, complete sentences. 25 | 26 | #### Modules 27 | 28 | - A *README.md* must be present. 29 | - Large functions must be placed in a *functions* directory. 30 | - Functions that take arguments must have completion. 31 | 32 | #### Themes 33 | 34 | - A screenshots section must be present in the file header. 35 | - The pull request description must have [embedded screenshots][5]. 36 | 37 | [1]: https://github.com/sorin-ionescu/prezto/contributors 38 | [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request 39 | [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 40 | [4]: https://help.github.com/articles/using-pull-requests 41 | [5]: http://daringfireball.net/projects/markdown/syntax#img 42 | 43 | -------------------------------------------------------------------------------- /modules/history/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets history options and defines history aliases. 3 | # 4 | # Authors: 5 | # Robby Russell 6 | # Sorin Ionescu 7 | # 8 | 9 | # 10 | # Variables 11 | # 12 | 13 | HISTFILE="${ZDOTDIR:-$HOME}/.zhistory" # The path to the history file. 14 | HISTSIZE=10000 # The maximum number of events to save in the internal history. 15 | SAVEHIST=10000 # The maximum number of events to save in the history file. 16 | 17 | # 18 | # Options 19 | # 20 | 21 | setopt BANG_HIST # Treat the '!' character specially during expansion. 22 | setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. 23 | setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. 24 | setopt SHARE_HISTORY # Share history between all sessions. 25 | setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history. 26 | setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again. 27 | setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. 28 | setopt HIST_FIND_NO_DUPS # Do not display a previously found event. 29 | setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. 30 | setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. 31 | setopt HIST_VERIFY # Do not execute immediately upon history expansion. 32 | setopt HIST_BEEP # Beep when accessing non-existent history. 33 | 34 | # 35 | # Aliases 36 | # 37 | 38 | # Lists the ten most used commands. 39 | alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" 40 | -------------------------------------------------------------------------------- /modules/history/README.md: -------------------------------------------------------------------------------- 1 | History 2 | ======= 3 | 4 | Sets [history][1] options and defines history aliases. 5 | 6 | Variables 7 | --------- 8 | 9 | - `HISTFILE` stores the path to the history file. 10 | - `HISTSIZE` stores the maximum number of events to save in the internal history. 11 | - `SAVEHIST` stores the maximum number of events to save in the history file. 12 | 13 | Options 14 | ------- 15 | 16 | - `BANG_HIST` treats the **!** character specially during expansion. 17 | - `EXTENDED_HISTORY` writes the history file in the *:start:elapsed;command* format. 18 | - `INC_APPEND_HISTORY` writes to the history file immediately, not when the shell exits. 19 | - `SHARE_HISTORY` shares history between all sessions. 20 | - `HIST_EXPIRE_DUPS_FIRST` expires a duplicate event first when trimming history. 21 | - `HIST_IGNORE_DUPS` does not record an event that was just recorded again. 22 | - `HIST_IGNORE_ALL_DUPS` deletes an old recorded event if a new event is a duplicate. 23 | - `HIST_FIND_NO_DUPS` does not display a previously found event. 24 | - `HIST_IGNORE_SPACE` does not record an event starting with a space. 25 | - `HIST_SAVE_NO_DUPS` does not write a duplicate event to the history file. 26 | - `HIST_VERIFY` does not execute immediately upon history expansion. 27 | - `HIST_BEEP` beeps when accessing non-existent history. 28 | 29 | Aliases 30 | ------- 31 | 32 | - `history-stat` lists the ten most used commands 33 | 34 | Authors 35 | ------- 36 | 37 | *The authors of this module should be contacted via the [issue tracker][2].* 38 | 39 | - [Robby Russell](https://github.com/robbyrussell) 40 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 41 | 42 | [1]: http://zsh.sourceforge.net/Guide/zshguide02.html#l16 43 | [2]: https://github.com/sorin-ionescu/prezto/issues 44 | 45 | -------------------------------------------------------------------------------- /modules/history-substring-search/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Integrates history-substring-search into Prezto. 3 | # 4 | # Authors: 5 | # Suraj N. Kurapati 6 | # Sorin Ionescu 7 | # 8 | 9 | # Load dependencies. 10 | pmodload 'editor' 11 | 12 | # Source module files. 13 | source "${0:h}/external/zsh-history-substring-search.zsh" || return 1 14 | 15 | # 16 | # Search 17 | # 18 | 19 | zstyle -s ':prezto:module:history-substring-search:color' found \ 20 | 'HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND' \ 21 | || HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' 22 | 23 | zstyle -s ':prezto:module:history-substring-search:color' not-found \ 24 | 'HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND' \ 25 | || HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' 26 | 27 | zstyle -s ':prezto:module:history-substring-search' globbing-flags \ 28 | 'HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS' \ 29 | || HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' 30 | 31 | if zstyle -t ':prezto:module:history-substring-search' case-sensitive; then 32 | HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS="${HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS//i}" 33 | fi 34 | 35 | if ! zstyle -t ':prezto:module:history-substring-search' color; then 36 | unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_{FOUND,NOT_FOUND} 37 | fi 38 | 39 | # 40 | # Key Bindings 41 | # 42 | 43 | if [[ -n "$key_info" ]]; then 44 | # Emacs 45 | bindkey -M emacs "$key_info[Control]P" history-substring-search-up 46 | bindkey -M emacs "$key_info[Control]N" history-substring-search-down 47 | 48 | # Vi 49 | bindkey -M vicmd "k" history-substring-search-up 50 | bindkey -M vicmd "j" history-substring-search-down 51 | 52 | # Emacs and Vi 53 | for keymap in 'emacs' 'viins'; do 54 | bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up 55 | bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down 56 | done 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /modules/environment/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets general shell options and defines environment variables. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # Smart URLs 10 | # 11 | 12 | autoload -Uz url-quote-magic 13 | zle -N self-insert url-quote-magic 14 | 15 | # 16 | # General 17 | # 18 | 19 | setopt BRACE_CCL # Allow brace character class list expansion. 20 | setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) 21 | # with the base character. 22 | setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. 23 | unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. 24 | 25 | # 26 | # Jobs 27 | # 28 | 29 | setopt LONG_LIST_JOBS # List jobs in the long format by default. 30 | setopt AUTO_RESUME # Attempt to resume existing job before creating a new process. 31 | setopt NOTIFY # Report status of background jobs immediately. 32 | unsetopt BG_NICE # Don't run all background jobs at a lower priority. 33 | unsetopt HUP # Don't kill jobs on shell exit. 34 | unsetopt CHECK_JOBS # Don't report on jobs when shell exit. 35 | 36 | # 37 | # Grep 38 | # 39 | 40 | if zstyle -t ':prezto:environment:grep' color; then 41 | export GREP_COLOR='37;45' 42 | export GREP_OPTIONS='--color=auto' 43 | fi 44 | 45 | # 46 | # Termcap 47 | # 48 | 49 | if zstyle -t ':prezto:environment:termcap' color; then 50 | export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking. 51 | export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold. 52 | export LESS_TERMCAP_me=$'\E[0m' # Ends mode. 53 | export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. 54 | export LESS_TERMCAP_so=$'\E[00;47;30m' # Begins standout-mode. 55 | export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. 56 | export LESS_TERMCAP_us=$'\E[01;32m' # Begins underline. 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /modules/perl/README.md: -------------------------------------------------------------------------------- 1 | Perl 2 | ==== 3 | 4 | Enables local [Perl][1] module installation on Mac OS X and defines alises. 5 | 6 | Local Module Installation 7 | ------------------------- 8 | 9 | Perl versions older than 5.14 do not support the local installation of Perl 10 | modules natively. This module allows for local installation of Perl modules on 11 | Mac OS X in *~/Library/Perl/5.12* by altering the environment. 12 | 13 | ### Usage 14 | 15 | For Perl versions older than 5.14, install *local::lib*. 16 | 17 | curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz 18 | tar xvf local-lib-1.008004.tar.gz 19 | cd local-lib-1.008004 20 | perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12 21 | make && make test && make install 22 | 23 | Install *cpanminus*: 24 | 25 | curl -L http://cpanmin.us | perl - --self-upgrade 26 | 27 | Perlbrew 28 | -------- 29 | 30 | An alternative to the above is to use [Perlbrew][2], which allows for the 31 | management of multiple, isolated Perl installations in the home directory. 32 | 33 | Aliases 34 | ------- 35 | 36 | ### General 37 | 38 | - `pl` is short for `perl`. 39 | - `pld` looks up Perl documentation (`perldoc`). 40 | - `ple` executes a one line program in a loop (`perl -wlne`). 41 | 42 | ### Perlbrew 43 | 44 | - `plb` manages Perl environments. 45 | - `plba` lists available Perl versions. 46 | - `plbi` installs a Perl version. 47 | - `plbl` lists installed Perl versions. 48 | - `plbo` temporarily turns off Perlbrew. 49 | - `plbO` turns off Perlbrew. 50 | - `plbs` switches to a Perl version. 51 | - `plbu` uninstalls a Perl version. 52 | - `plbx` temporarily sets the Perl version to use. 53 | 54 | Authors 55 | ------- 56 | 57 | *The authors of this module should be contacted via the [issue tracker][3].* 58 | 59 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 60 | 61 | [1]: http://www.perl.org 62 | [2]: http://perlbrew.pl 63 | [3]: https://github.com/sorin-ionescu/prezto/issues 64 | 65 | -------------------------------------------------------------------------------- /modules/syntax-highlighting/README.md: -------------------------------------------------------------------------------- 1 | Syntax Highlighting 2 | =================== 3 | 4 | Integrates [zsh-syntax-highlighting][1] into Prezto. 5 | 6 | This module should be loaded *second to last*, where last is the *prompt* 7 | module, unless used in conjuncture with the *history-substring-search* module 8 | where it must be loaded **before** it. 9 | 10 | Contributors 11 | ------------ 12 | 13 | New features and bug fixes should be submitted to the 14 | [zsh-syntax-highlighting][1] project according to its rules and regulations. 15 | This module will be synchronized against it. 16 | 17 | Settings 18 | -------- 19 | 20 | ### Highlighting 21 | 22 | To enable highlighting for this module only, add the following line to 23 | *zpreztorc*: 24 | 25 | zstyle ':prezto:module:syntax-highlighting' color 'yes' 26 | 27 | ### Highlighters 28 | 29 | Syntax highlighting is accomplished by pluggable [highlighters][2]. This module 30 | enables the *main*, *brackets*, and *cursor* highlighters by default. 31 | 32 | To enable all highlighters, add the following to *zpreztorc*: 33 | 34 | zstyle ':prezto:module:syntax-highlighting' highlighters \ 35 | 'main' \ 36 | 'brackets' \ 37 | 'pattern' \ 38 | 'cursor' \ 39 | 'root' 40 | 41 | ### Highlighting Styles 42 | 43 | Each syntax highlighter defines styles used to highlight tokens. 44 | 45 | To highlight, for example, builtins, commands, and functions in blue instead of 46 | green, add the following to *zpreztorc*: 47 | 48 | zstyle ':prezto:module:syntax-highlighting' styles \ 49 | 'builtin' 'bg=blue' \ 50 | 'command' 'bg=blue' \ 51 | 'function' 'bg=blue' 52 | 53 | Authors 54 | ------- 55 | 56 | *The authors of this module should be contacted via the [issue tracker][3].* 57 | 58 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 59 | 60 | [1]: https://github.com/zsh-users/zsh-syntax-highlighting 61 | [2]: https://github.com/zsh-users/zsh-syntax-highlighting/tree/master/highlighters 62 | [3]: https://github.com/sorin-ionescu/prezto/issues 63 | 64 | -------------------------------------------------------------------------------- /modules/ruby/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Configures Ruby local gem installation, loads version managers, and defines 3 | # aliases. 4 | # 5 | # Authors: Sorin Ionescu 6 | # 7 | 8 | # Load RVM into the shell session. 9 | if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then 10 | # Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list 11 | # conflicts with RVM. 12 | unsetopt AUTO_NAME_DIRS 13 | 14 | # Source RVM. 15 | source "$HOME/.rvm/scripts/rvm" 16 | 17 | # Load manually installed rbenv into the shell session. 18 | elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then 19 | path=("$HOME/.rbenv/bin" $path) 20 | eval "$(rbenv init - --no-rehash zsh)" 21 | 22 | # Load package manager installed rbenv into the shell session. 23 | elif (( $+commands[rbenv] )); then 24 | eval "$(rbenv init - --no-rehash zsh)" 25 | 26 | # Load package manager installed chruby into the shell session. 27 | elif (( $+commands[chruby-exec] )); then 28 | source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" 29 | if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then 30 | source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" 31 | fi 32 | 33 | # Prepend local gems bin directories to PATH. 34 | else 35 | path=($HOME/.gem/ruby/*/bin(N) $path) 36 | fi 37 | 38 | # Return if requirements are not found. 39 | if (( ! $+commands[ruby] && ! ( $+commands[rvm] || $+commands[rbenv] ) )); then 40 | return 1 41 | fi 42 | 43 | # 44 | # Aliases 45 | # 46 | 47 | # General 48 | alias rb='ruby' 49 | 50 | # Bundler 51 | if (( $+commands[bundle] )); then 52 | alias rbb='bundle' 53 | alias rbbe='bundle exec' 54 | alias rbbi='bundle install --path vendor/bundle' 55 | alias rbbl='bundle list' 56 | alias rbbo='bundle open' 57 | alias rbbp='bundle package' 58 | alias rbbu='bundle update' 59 | alias rbbI='rbbi \ 60 | && bundle package \ 61 | && print .bundle >>! .gitignore \ 62 | && print vendor/assets >>! .gitignore \ 63 | && print vendor/bundle >>! .gitignore \ 64 | && print vendor/cache >>! .gitignore' 65 | fi 66 | 67 | -------------------------------------------------------------------------------- /modules/editor/README.md: -------------------------------------------------------------------------------- 1 | Editor 2 | ====== 3 | 4 | Sets key bindings. 5 | 6 | Settings 7 | -------- 8 | 9 | ### Key bindings 10 | 11 | To enable key bindings, add the following to *zpreztorc*, and replace 'bindings' 12 | with 'emacs' or 'vi'. 13 | 14 | zstyle ':prezto:module:editor' key-bindings 'bindings' 15 | 16 | ### Dot Expansion 17 | 18 | To enable the auto conversion of .... to ../.., add the following to 19 | *zpreztorc*. 20 | 21 | zstyle ':prezto:module:editor' dot-expansion 'yes' 22 | 23 | Theming 24 | ------- 25 | 26 | To indicate when the editor is in the primary keymap (emacs or viins), add 27 | the following to your `theme_prompt_setup` function. 28 | 29 | zstyle ':prezto:module:editor:info:keymap:primary' format '>>>' 30 | 31 | To indicate when the editor is in the primary keymap (emacs or viins) insert 32 | mode, add the following to your `theme_prompt_setup` function. 33 | 34 | zstyle ':prezto:module:editor:info:keymap:primary:insert' format 'I' 35 | 36 | To indicate when the editor is in the primary keymap (emacs or viins) overwrite 37 | mode, add the following to your `theme_prompt_setup` function. 38 | 39 | zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format 'O' 40 | 41 | To indicate when the editor is in the alternate keymap (vicmd), add the 42 | following to your `theme_prompt_setup` function. 43 | 44 | zstyle ':prezto:module:editor:info:keymap:alternate' format '<<<' 45 | 46 | To indicate when the editor is completing, add the following to your 47 | `theme_prompt_setup` function. 48 | 49 | zstyle ':prezto:module:editor:info:completing' format '...' 50 | 51 | Then add `$editor_info[context]`, where context is *keymap*, *insert*, or 52 | *overwrite*, to `$PROMPT` or `$RPROMPT` and call `editor-info` in the 53 | `prompt_name_preexec` hook function. 54 | 55 | Authors 56 | ------- 57 | 58 | *The authors of this module should be contacted via the [issue tracker][1].* 59 | 60 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 61 | 62 | [1]: https://github.com/sorin-ionescu/oh-my-zsh/issues 63 | 64 | -------------------------------------------------------------------------------- /runcoms/zshrc: -------------------------------------------------------------------------------- 1 | # 2 | # Executes commands at the start of an interactive session. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Source Prezto. 9 | if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then 10 | source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" 11 | fi 12 | 13 | 14 | # Customize to your needs... 15 | 16 | # Update Pretzo 17 | alias update_pretzo="cd ~/.zprezto/ && git submodule foreach git reset --hard && git pull && git submodule update --init --recursive" 18 | 19 | alias show_hidden_files="defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app" 20 | 21 | alias hide_hidden_files="defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app 22 | " 23 | # Switch to master branch and pull 24 | alias gmp="git co master && git pull --prune" 25 | 26 | # Run migrations 27 | alias dbm="bin/rake db:migrate && sr" 28 | 29 | # Undo schema.rb changes 30 | alias sr="git co -- db/structure.sql" 31 | 32 | # Git goodies 33 | alias gg='noglob gg' 34 | 35 | # script/server 36 | alias ss="script/server" 37 | 38 | # git jk 39 | alias gitjk="history 10 | tail -r | gitjk_cmd" 40 | 41 | # Make `rm` put stuff in trash 42 | alias rm="trash" 43 | 44 | # zmv ftw 45 | autoload -U zmv 46 | # alias for zmv for no quotes 47 | # mmv *.c.orig orig/*.c 48 | alias mmv='noglob zmv -W' 49 | 50 | # fix duplicate "open with" entries 51 | alias fixopenwith='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder' 52 | 53 | # This is needed for hub/git autocompletion 54 | setopt complete_aliases 55 | 56 | export EDITOR=vim 57 | export VISUAL=vim 58 | 59 | export GOPATH=$HOME 60 | export PATH="$HOME/bin:$PATH" 61 | export PATH="/opt/boxen/nodenv/versions/v0.10/bin:$PATH" 62 | export PATH="$PATH:$GOPATH/bin" 63 | 64 | export PATH="$HOME/.rbenv/bin:$PATH" 65 | eval "$(rbenv init -)" 66 | eval "$(fasd --init auto)" 67 | 68 | [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 69 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_nicoulaj_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A simple theme that displays only relevant information. 3 | # 4 | # Authors: 5 | # Julien Nicoulaud 6 | # Sorin Ionescu 7 | # 8 | # Features: 9 | # - One line. 10 | # - VCS information in the right prompt. 11 | # - Only shows the path on the left prompt by default. 12 | # - Crops the path to a defined length and only shows the path relative to 13 | # the current VCS repository root. 14 | # - Uses a different color depending on if the last command succeeded/failed. 15 | # - Shows user@hostname if connected through SSH. 16 | # - Shows if logged in as root or not. 17 | # 18 | # Screenshots: 19 | # http://i.imgur.com/Xe1bu.png 20 | # 21 | 22 | function prompt_nicoulaj_precmd { 23 | vcs_info 24 | } 25 | 26 | function prompt_nicoulaj_setup { 27 | setopt LOCAL_OPTIONS 28 | unsetopt XTRACE KSH_ARRAYS 29 | prompt_opts=(cr percent subst) 30 | 31 | # Load required functions. 32 | autoload -Uz add-zsh-hook 33 | autoload -Uz vcs_info 34 | 35 | # Add hook for calling vcs_info before each command. 36 | add-zsh-hook precmd prompt_nicoulaj_precmd 37 | 38 | # Customizable parameters. 39 | local max_path_chars=30 40 | local user_char='❯' 41 | local root_char='❯❯❯' 42 | local success_color='%F{071}' 43 | local failure_color='%F{124}' 44 | local vcs_info_color='%F{242}' 45 | 46 | # Set vcs_info parameters. 47 | zstyle ':vcs_info:*' enable bzr git hg svn 48 | zstyle ':vcs_info:*' check-for-changes true 49 | zstyle ':vcs_info:*' unstagedstr '!' 50 | zstyle ':vcs_info:*' stagedstr '+' 51 | zstyle ':vcs_info:*' actionformats "%S" "%r/%s/%b %u%c (%a)" 52 | zstyle ':vcs_info:*' formats "%S" "%r/%s/%b %u%c" 53 | zstyle ':vcs_info:*' nvcsformats "%~" "" 54 | 55 | # Define prompts. 56 | PROMPT="%(?.${success_color}.${failure_color})${SSH_TTY:+[%n@%m]}%B%${max_path_chars}<...<"'${vcs_info_msg_0_%%.}'"%<<%(!.${root_char}.${user_char})%b%f " 57 | RPROMPT="${vcs_info_color}"'${vcs_info_msg_1_}'"%f" 58 | } 59 | 60 | prompt_nicoulaj_setup "$@" 61 | 62 | -------------------------------------------------------------------------------- /modules/archive/functions/unarchive: -------------------------------------------------------------------------------- 1 | # 2 | # Extracts the contents of archives. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | local remove_archive 9 | local success 10 | local file_name 11 | local extract_dir 12 | 13 | if (( $# == 0 )); then 14 | cat >&2 <. 21 | EOF 22 | fi 23 | 24 | remove_archive=1 25 | if [[ "$1" == "-r" || "$1" == "--remove" ]]; then 26 | remove_archive=0 27 | shift 28 | fi 29 | 30 | while (( $# > 0 )); do 31 | if [[ ! -s "$1" ]]; then 32 | print "$0: file not valid: $1" >&2 33 | shift 34 | continue 35 | fi 36 | 37 | success=0 38 | file_name="${1:t}" 39 | extract_dir="${file_name:r}" 40 | case "$1" in 41 | (*.tar.gz|*.tgz) tar xvzf "$1" ;; 42 | (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; 43 | (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ 44 | && tar --xz -xvf "$1" \ 45 | || xzcat "$1" | tar xvf - ;; 46 | (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ 47 | && tar --lzma -xvf "$1" \ 48 | || lzcat "$1" | tar xvf - ;; 49 | (*.tar) tar xvf "$1" ;; 50 | (*.gz) gunzip "$1" ;; 51 | (*.bz2) bunzip2 "$1" ;; 52 | (*.xz) unxz "$1" ;; 53 | (*.lzma) unlzma "$1" ;; 54 | (*.Z) uncompress "$1" ;; 55 | (*.zip) unzip "$1" -d $extract_dir ;; 56 | (*.rar) unrar &> /dev/null \ 57 | && unrar e -ad "$1" \ 58 | || rar e -ad "$1" ;; 59 | (*.7z) 7za x "$1" ;; 60 | (*.deb) 61 | mkdir -p "$extract_dir/control" 62 | mkdir -p "$extract_dir/data" 63 | cd "$extract_dir"; ar vx "../${1}" > /dev/null 64 | cd control; tar xzvf ../control.tar.gz 65 | cd ../data; tar xzvf ../data.tar.gz 66 | cd ..; rm *.tar.gz debian-binary 67 | cd .. 68 | ;; 69 | (*) 70 | print "$0: cannot extract: $1" >&2 71 | success=1 72 | ;; 73 | esac 74 | 75 | (( success = $success > 0 ? $success : $? )) 76 | (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" 77 | shift 78 | done 79 | 80 | -------------------------------------------------------------------------------- /modules/history-substring-search/README.md: -------------------------------------------------------------------------------- 1 | History Substring Search 2 | ======================== 3 | 4 | Integrates [zsh-history-substring-search][1] into Prezto, which implements 5 | the [Fish shell][2]'s history search feature, where the user can type in any 6 | part of a previously entered command and press up and down to cycle through 7 | matching commands. 8 | 9 | If this module is used in conjuncture with the *syntax-highlighting* module, it 10 | must be loaded **after** it. 11 | 12 | Contributors 13 | ------------ 14 | 15 | New features and bug fixes should be submitted to the 16 | [zsh-history-substring-search][1] project according to its rules and 17 | regulations. This module will be synchronized against it. 18 | 19 | Settings 20 | -------- 21 | 22 | ### Case Sensitivity 23 | 24 | To enable case-sensitivity for this module only, add the following line to 25 | *zpreztorc*: 26 | 27 | zstyle ':prezto:module:history-substring-search' case-sensitive 'yes' 28 | 29 | ### Highlighting 30 | 31 | If colors are enabled, *history-substring-search* will automatically highlight 32 | positive results. 33 | 34 | To enable highlighting for this module only, add the following line to 35 | *zpreztorc*: 36 | 37 | zstyle ':prezto:module:history-substring-search' color 'yes' 38 | 39 | To set the query found color, add the following line to *zpreztorc*: 40 | 41 | zstyle ':prezto:module:history-substring-search:color' found '' 42 | 43 | To set the query not found color, add the following line to *zpreztorc*: 44 | 45 | zstyle ':prezto:module:history-substring-search:color' not-found '' 46 | 47 | To set the search globbing flags, add the following line to *zpreztorc*: 48 | 49 | zstyle ':prezto:module:history-substring-search' globbing-flags '' 50 | 51 | Authors 52 | ------- 53 | 54 | *The authors of this module should be contacted via the [issue tracker][3].* 55 | 56 | - [Suraj N. Kurapati](https://github.com/sunaku) 57 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 58 | 59 | [1]: https://github.com/zsh-users/zsh-history-substring-search 60 | [2]: http://fishshell.com 61 | [3]: https://github.com/sorin-ionescu/prezto/issues 62 | 63 | -------------------------------------------------------------------------------- /modules/pacman/README.md: -------------------------------------------------------------------------------- 1 | Pacman 2 | ====== 3 | 4 | Provides aliases and functions for the [Pacman][1] package manager and 5 | frontends. 6 | 7 | Settings 8 | -------- 9 | 10 | To enable a Pacman frontend, for example, [Yaourt][2], add the following line to 11 | *zpreztorc*: 12 | 13 | zstyle ':prezto:module:pacman' frontend 'yaourt' 14 | 15 | If you have enabled color globally in *zpreztorc*, you may disable it for certain 16 | commands. 17 | 18 | To disable `yaourt` highlighting, add the following line to *zpreztorc*: 19 | 20 | zstyle ':prezto:module:pacman:yaourt' color 'no' 21 | 22 | Aliases 23 | ------- 24 | 25 | ### Pacman 26 | 27 | - `pac` is short for `pacman`. 28 | - `paci` installs packages from repositories. 29 | - `pacI` installs packages from files. 30 | - `pacx` removes packages and unneeded dependencies. 31 | - `pacX` removes packages, their configuration, and unneeded dependencies. 32 | - `pacq` displays information about a package from the repositories. 33 | - `pacQ` displays information about a package from the local database. 34 | - `pacs` searches for packages in the repositories. 35 | - `pacS` searches for packages in the local database. 36 | - `pacu` synchronizes the local package and Arch Build System (requires `abs`) 37 | databases against the repositories. 38 | - `pacU` synchronizes the local package database against the repositories then 39 | upgrades outdated packages. 40 | - `pacman-list-orphans` lists orphan packages. 41 | - `pacman-remove-orphans` removes orphan packages. 42 | 43 | ### Frontends 44 | 45 | #### Yaourt 46 | 47 | - `pacc` manages *.pac\** files. 48 | 49 | Functions 50 | --------- 51 | 52 | - `pacman-list-explicit` lists explicitly installed pacman packages. 53 | - `pacman-list-disowned` lists pacman disowned files. 54 | 55 | Authors 56 | ------- 57 | 58 | *The authors of this module should be contacted via the [issue tracker][3].* 59 | 60 | - [Benjamin Boudreau](https://github.com/dreur) 61 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 62 | 63 | [1]: http://www.archlinux.org/pacman/ 64 | [2]: http://archlinux.fr/yaourt-en 65 | [3]: https://github.com/sorin-ionescu/prezto/issues 66 | 67 | -------------------------------------------------------------------------------- /modules/gnu-utility/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Provides for the interactive use of GNU utilities on BSD systems. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Get the prefix or use the default. 9 | zstyle -s ':prezto:module:gnu-utility' prefix '_gnu_utility_p' || _gnu_utility_p='g' 10 | 11 | # Return if requirements are not found. 12 | if (( ! ${+commands[${_gnu_utility_p}whoami]} )); then 13 | return 1 14 | fi 15 | 16 | _gnu_utility_cmds=( 17 | # Coreutils 18 | '[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown' 19 | 'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df' 20 | 'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr' 21 | 'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id' 22 | 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum' 23 | 'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc' 24 | 'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx' 25 | 'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum' 26 | 'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf' 27 | 'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail' 28 | 'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort' 29 | 'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir' 30 | 'wc' 'who' 'whoami' 'yes' 31 | 32 | # The following utilities are not part of Coreutils but installed separately. 33 | 34 | # Binutils 35 | 'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump' 36 | 'ranlib' 'readelf' 'size' 'strings' 'strip' 37 | 38 | # Findutils 39 | 'find' 'locate' 'oldfind' 'updatedb' 'xargs' 40 | 41 | # Libtool 42 | 'libtool' 'libtoolize' 43 | 44 | # Miscellaneous 45 | 'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which' 46 | ) 47 | 48 | # Wrap GNU utilities in functions. 49 | for _gnu_utility_cmd in "${_gnu_utility_cmds[@]}"; do 50 | _gnu_utility_pcmd="${_gnu_utility_p}${_gnu_utility_cmd}" 51 | if (( ${+commands[${_gnu_utility_pcmd}]} )); then 52 | eval " 53 | function ${_gnu_utility_cmd} { 54 | '${commands[${_gnu_utility_pcmd}]}' \"\$@\" 55 | } 56 | " 57 | fi 58 | done 59 | 60 | unset _gnu_utility_{p,cmds,cmd,pcmd} 61 | 62 | -------------------------------------------------------------------------------- /modules/tmux/README.md: -------------------------------------------------------------------------------- 1 | Tmux 2 | ==== 3 | 4 | Defines [tmux][1] aliases and provides for auto launching it at start-up. 5 | 6 | Settings 7 | -------- 8 | 9 | ### Auto-Start 10 | 11 | Starts a tmux session automatically when Zsh is launched. 12 | 13 | To enable this feature when launching Zsh in a local terminal, add the 14 | following line to *zpreztorc*: 15 | 16 | zstyle ':prezto:module:tmux:auto-start' local 'yes' 17 | 18 | To enable this feature when launching Zsh in a SSH connection, add the 19 | following line to *zpreztorc*: 20 | 21 | zstyle ':prezto:module:tmux:auto-start' remote 'yes' 22 | 23 | In both cases, it will create a background session named _prezto_ if the tmux 24 | server is not started. 25 | 26 | With `auto-start` enabled, you may want to control how multiple sessions are 27 | managed. The `destroy-unattached` option of tmux controls if the unattached 28 | sessions must be kept alive, making sessions available for later use, configured 29 | in *tmux.conf*: 30 | 31 | set-option -g destroy-unattached [on | off] 32 | 33 | Aliases 34 | ------- 35 | 36 | - `tmuxa` attaches or switches to a tmux session. 37 | - `tmuxl` lists sessions managed by the tmux server. 38 | 39 | Caveats 40 | ------- 41 | 42 | On Mac OS X, launching tmux can cause the error **launch_msg(...): Socket is not 43 | connected** to be displayed, which can be fixed by installing 44 | [reattach-to-user-namespace][3], available in [Homebrew][4], and adding the 45 | following to *tmux.conf*: 46 | 47 | set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" 48 | 49 | Furthermore, tmux is known to cause **kernel panics** on Mac OS X. A discussion 50 | about this and Prezto has already been [opened][2]. 51 | 52 | Authors 53 | ------- 54 | 55 | *The authors of this module should be contacted via the [issue tracker][5].* 56 | 57 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 58 | - [Colin Hebert](https://github.com/ColinHebert) 59 | - [Georges Discry](https://github.com/gdiscry) 60 | - [Xavier Cambar](https://github.com/xcambar) 61 | 62 | [1]: http://tmux.sourceforge.net 63 | [2]: https://github.com/sorin-ionescu/prezto/issues/62 64 | [3]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard 65 | [4]: https://github.com/mxcl/homebrew 66 | [5]: https://github.com/sorin-ionescu/prezto/issues 67 | 68 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_peepcode_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A simple theme from PeepCode. 3 | # http://peepcode.com/blog/2012/my-command-line-prompt 4 | # 5 | # Authors: 6 | # Geoffrey Grosenbach 7 | # Sorin Ionescu 8 | # 9 | # Screenshots: 10 | # http://i.imgur.com/LhgmW.png 11 | # 12 | 13 | function +vi-git-status() { 14 | # Check for untracked files or updated submodules since vcs_info does not. 15 | if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then 16 | hook_com[unstaged]=' %F{8}✗%f' 17 | fi 18 | } 19 | 20 | function prompt_peepcode_precmd { 21 | vcs_info 22 | 23 | if (( $+functions[ruby-info] )); then 24 | ruby-info 25 | fi 26 | } 27 | 28 | function prompt_peepcode_setup { 29 | setopt LOCAL_OPTIONS 30 | unsetopt XTRACE KSH_ARRAYS 31 | prompt_opts=(cr percent subst) 32 | 33 | # Load required functions. 34 | autoload -Uz add-zsh-hook 35 | autoload -Uz vcs_info 36 | 37 | # Add hook for calling vcs_info before each command. 38 | add-zsh-hook precmd prompt_peepcode_precmd 39 | 40 | # Set vcs_info parameters. 41 | zstyle ':vcs_info:*' enable git 42 | zstyle ':vcs_info:*' check-for-changes true 43 | zstyle ':vcs_info:*' get-revision true 44 | zstyle ':vcs_info:*' use-simple true 45 | zstyle ':vcs_info:*' unstagedstr ' %F{8}✗%f' 46 | zstyle ':vcs_info:*' formats ' %F{8}%b%f %F{white}%.7i%f%u' 47 | zstyle ':vcs_info:*' actionformats ' %F{8}%b%f %F{white}%.7i%f +%a%u' 48 | zstyle ':vcs_info:git*+set-message:*' hooks git-status 49 | 50 | # Set ruby-info parameters. 51 | zstyle ':prezto:module:ruby:info:version' format ' %F{white}%v%f' 52 | 53 | # Define prompts. 54 | PROMPT=" 55 | %~ 56 | %(?.%F{green}${1:-☻ }%f.%F{red}${1:-☻ }%f) " 57 | RPROMPT='${ruby_info[version]}${vcs_info_msg_0_}' 58 | 59 | } 60 | 61 | function prompt_peepcode_help { 62 | cat <] 66 | 67 | If this option is not provided, the symbol defaults to ☻. 68 | EOH 69 | } 70 | 71 | function prompt_peepcode_preview { 72 | local +h PROMPT='%# ' 73 | local +h RPROMPT='' 74 | local +h SPROMPT='' 75 | 76 | if (( $# > 0 )); then 77 | prompt_preview_theme 'peepcode' "$@" 78 | else 79 | prompt_preview_theme 'peepcode' 80 | print 81 | prompt_preview_theme 'peepcode' "❯" 82 | print 83 | prompt_preview_theme 'peepcode' "$" 84 | fi 85 | } 86 | 87 | prompt_peepcode_setup "$@" 88 | 89 | -------------------------------------------------------------------------------- /runcoms/README.md: -------------------------------------------------------------------------------- 1 | Configuration Files 2 | =================== 3 | 4 | Zsh has several system-wide and user-local configuration files. 5 | 6 | Prezto has one user-local configuration file. 7 | 8 | System-wide configuration files are installation-dependent but are installed 9 | in */etc* by default. 10 | 11 | User-local configuration files have the same name as their global counterparts 12 | but are prefixed with a dot (hidden). Zsh looks for these files in the path 13 | stored in the `$ZDOTDIR` environmental variable. However, if said variable is 14 | not defined, Zsh will use the user's home directory. 15 | 16 | File Descriptions 17 | ----------------- 18 | 19 | The configuration files are read in the following order: 20 | 21 | 01. /etc/zshenv 22 | 02. ~/.zshenv 23 | 03. /etc/zprofile 24 | 04. ~/.zprofile 25 | 05. /etc/zshrc 26 | 06. ~/.zshrc 27 | 07. ~/.zpreztorc 28 | 08. /etc/zlogin 29 | 09. ~/.zlogin 30 | 10. ~/.zlogout 31 | 11. /etc/zlogout 32 | 33 | ### zshenv 34 | 35 | This file is sourced by all instances of Zsh, and thus, it should be kept as 36 | small as possible and should only define environment variables. 37 | 38 | ### zprofile 39 | 40 | This file is similar to zlogin, but it is sourced before zshrc. It was added 41 | for [KornShell][1] fans. See the description of zlogin below for what it may 42 | contain. 43 | 44 | zprofile and zlogin are not meant to be used concurrently but can be done so. 45 | 46 | ### zshrc 47 | 48 | This file is sourced by interactive shells. It should define aliases, 49 | functions, shell options, and key bindings. 50 | 51 | ### zpreztorc 52 | 53 | This file configures Prezto. 54 | 55 | ### zlogin 56 | 57 | This file is sourced by login shells after zshrc, and thus, it should contain 58 | commands that need to execute at login. It is usually used for messages such as 59 | [fortune][2], [msgs][3], or for the creation of files. 60 | 61 | This is not the file to define aliases, functions, shell options, and key 62 | bindings. It should not change the shell environment. 63 | 64 | ### zlogout 65 | 66 | This file is sourced by login shells during logout. It should be used for 67 | displaying messages and the deletion of files. 68 | 69 | Authors 70 | ------- 71 | 72 | *The authors of these files should be contacted via the [issue tracker][4].* 73 | 74 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 75 | 76 | [1]: http://www.kornshell.com 77 | [2]: http://en.wikipedia.org/wiki/Fortune_(Unix) 78 | [3]: http://www.manpagez.com/man/1/msgs 79 | [4]: https://github.com/sorin-ionescu/prezto/issues 80 | 81 | -------------------------------------------------------------------------------- /modules/pacman/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Pacman aliases. 3 | # 4 | # Authors: 5 | # Benjamin Boudreau 6 | # Sorin Ionescu 7 | # 8 | # Tips: 9 | # https://wiki.archlinux.org/index.php/Pacman_Tips 10 | # 11 | 12 | # Return if requirements are not found. 13 | if (( ! $+commands[pacman] )); then 14 | return 1 15 | fi 16 | 17 | # 18 | # Frontend 19 | # 20 | 21 | # Get the Pacman frontend. 22 | zstyle -s ':prezto:module:pacman' frontend '_pacman_frontend' 23 | 24 | if (( $+commands[$_pacman_frontend] )); then 25 | alias pacman="$_pacman_frontend" 26 | 27 | if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then 28 | source "${0:h}/${_pacman_frontend}.zsh" 29 | fi 30 | else 31 | _pacman_frontend='pacman' 32 | _pacman_sudo='sudo ' 33 | fi 34 | 35 | # 36 | # Aliases 37 | # 38 | 39 | # Pacman. 40 | alias pac="${_pacman_frontend}" 41 | 42 | # Installs packages from repositories. 43 | alias paci="${_pacman_sudo}${_pacman_frontend} --sync" 44 | 45 | # Installs packages from files. 46 | alias pacI="${_pacman_sudo}${_pacman_frontend} --upgrade" 47 | 48 | # Removes packages and unneeded dependencies. 49 | alias pacx="${_pacman_sudo}${_pacman_frontend} --remove" 50 | 51 | # Removes packages, their configuration, and unneeded dependencies. 52 | alias pacX="${_pacman_sudo}${_pacman_frontend} --remove --nosave --recursive" 53 | 54 | # Displays information about a package from the repositories. 55 | alias pacq="${_pacman_frontend} --sync --info" 56 | 57 | # Displays information about a package from the local database. 58 | alias pacQ="${_pacman_frontend} --query --info" 59 | 60 | # Searches for packages in the repositories. 61 | alias pacs="${_pacman_frontend} --sync --search" 62 | 63 | # Searches for packages in the local database. 64 | alias pacS="${_pacman_frontend} --query --search" 65 | 66 | # Lists orphan packages. 67 | alias pacman-list-orphans="${_pacman_sudo}${_pacman_frontend} --query --deps --unrequired" 68 | 69 | # Removes orphan packages. 70 | alias pacman-remove-orphans="${_pacman_sudo}${_pacman_frontend} --remove --recursive \$(${_pacman_frontend} --quiet --query --deps --unrequired)" 71 | 72 | # Synchronizes the local package and Arch Build System databases against the 73 | # repositories. 74 | if (( $+commands[abs] )); then 75 | alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && ${_pacman_sudo}abs" 76 | else 77 | alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh" 78 | fi 79 | 80 | # Synchronizes the local package database against the repositories then 81 | # upgrades outdated packages. 82 | alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade" 83 | 84 | unset _pacman_{frontend,sudo} 85 | 86 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_jason_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A simple theme that displays relevant, contextual information. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | # Screenshots: 8 | # http://i.imgur.com/nBEEZ.png 9 | # 10 | 11 | # Load dependencies. 12 | pmodload 'helper' 13 | 14 | function prompt_sorin_pwd { 15 | _prompt_sorin_pwd="${PWD/#$HOME/~}" 16 | } 17 | 18 | function prompt_sorin_precmd { 19 | setopt LOCAL_OPTIONS 20 | unsetopt XTRACE KSH_ARRAYS 21 | 22 | # Format PWD. 23 | prompt_sorin_pwd 24 | 25 | # Get Git repository information. 26 | if (( $+functions[git-info] )); then 27 | git-info 28 | fi 29 | } 30 | 31 | function prompt_sorin_setup { 32 | setopt LOCAL_OPTIONS 33 | unsetopt XTRACE KSH_ARRAYS 34 | prompt_opts=(cr percent subst) 35 | 36 | # Load required functions. 37 | autoload -Uz add-zsh-hook 38 | 39 | # Add hook for calling git-info before each command. 40 | add-zsh-hook precmd prompt_sorin_precmd 41 | 42 | # Set editor-info parameters. 43 | zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' 44 | zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{blue}➜%f%b' 45 | zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%B%F{blue}➜%f%b' 46 | zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{red}✕%f%b' 47 | 48 | # Set git-info parameters. 49 | zstyle ':prezto:module:git:info' verbose 'yes' 50 | # zstyle ':prezto:module:git:info:action' format '%%B%F{yellow}%s%f%%b' 51 | # zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b' 52 | # zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b' 53 | # zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b' 54 | zstyle ':prezto:module:git:info:branch' format '%F{magenta}%b%f' 55 | # zstyle ':prezto:module:git:info:commit' format '%F{green}%.7c%f' 56 | # zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b' 57 | # zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b' 58 | zstyle ':prezto:module:git:info:modified' format ' %F{red}✱%f%b' 59 | # zstyle ':prezto:module:git:info:position' format '%F{red}%p%f' 60 | # zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b' 61 | # zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b' 62 | # zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b' 63 | # zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b' 64 | zstyle ':prezto:module:git:info:keys' format \ 65 | 'prompt' ' %B%F{white}on %f$(coalesce "%b" "%p" "%c")%s' \ 66 | 'rprompt' '%A%B%S%a%d%m%r%U%u' 67 | 68 | # Define prompts. 69 | PROMPT=' 70 | %F{green}${_prompt_sorin_pwd}%f${${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.) 71 | ${editor_info[keymap]} ' 72 | RPROMPT='${editor_info[overwrite]}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}' 73 | SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' 74 | } 75 | 76 | prompt_sorin_setup "$@" 77 | 78 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_steeef_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. 3 | # 4 | # Authors: 5 | # Steve Losh 6 | # Bart Trojanowski 7 | # Brian Carper 8 | # steeef 9 | # Sorin Ionescu 10 | # 11 | # Screenshots: 12 | # http://i.imgur.com/HyRvv.png 13 | # 14 | 15 | function prompt_steeef_precmd { 16 | # Check for untracked files or updated submodules since vcs_info does not. 17 | if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then 18 | branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)" 19 | else 20 | branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)" 21 | fi 22 | 23 | zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" 24 | 25 | vcs_info 'prompt' 26 | 27 | if (( $+functions[python-info] )); then 28 | python-info 29 | fi 30 | } 31 | 32 | function prompt_steeef_setup { 33 | setopt LOCAL_OPTIONS 34 | unsetopt XTRACE KSH_ARRAYS 35 | prompt_opts=(cr percent subst) 36 | 37 | # Load required functions. 38 | autoload -Uz add-zsh-hook 39 | autoload -Uz vcs_info 40 | 41 | # Add hook for calling vcs_info before each command. 42 | add-zsh-hook precmd prompt_steeef_precmd 43 | 44 | # Use extended color pallete if available. 45 | if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then 46 | _prompt_steeef_colors=( 47 | "%F{81}" # Turquoise 48 | "%F{166}" # Orange 49 | "%F{135}" # Purple 50 | "%F{161}" # Hotpink 51 | "%F{118}" # Limegreen 52 | ) 53 | else 54 | _prompt_steeef_colors=( 55 | "%F{cyan}" 56 | "%F{yellow}" 57 | "%F{magenta}" 58 | "%F{red}" 59 | "%F{green}" 60 | ) 61 | fi 62 | 63 | # Formats: 64 | # %b - branchname 65 | # %u - unstagedstr (see below) 66 | # %c - stagedstr (see below) 67 | # %a - action (e.g. rebase-i) 68 | # %R - repository path 69 | # %S - path in the repository 70 | local branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)" 71 | local action_format="(${_prompt_steeef_colors[5]}%a%f)" 72 | local unstaged_format="${_prompt_steeef_colors[2]}●%f" 73 | local staged_format="${_prompt_steeef_colors[5]}●%f" 74 | 75 | # Set vcs_info parameters. 76 | zstyle ':vcs_info:*' enable bzr git hg svn 77 | zstyle ':vcs_info:*:prompt:*' check-for-changes true 78 | zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" 79 | zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" 80 | zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" 81 | zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" 82 | zstyle ':vcs_info:*:prompt:*' nvcsformats "" 83 | 84 | # Set python-info parameters. 85 | zstyle ':prezto:module:python:info:virtualenv' format '(%v)' 86 | 87 | # Define prompts. 88 | PROMPT=" 89 | ${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'" 90 | "'$python_info[virtualenv]'"$ " 91 | RPROMPT='' 92 | } 93 | 94 | prompt_steeef_setup "$@" 95 | 96 | -------------------------------------------------------------------------------- /modules/prompt/functions/prompt_sorin_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A simple theme that displays relevant, contextual information. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | # Screenshots: 8 | # http://i.imgur.com/nBEEZ.png 9 | # 10 | 11 | # Load dependencies. 12 | pmodload 'helper' 13 | 14 | function prompt_sorin_pwd { 15 | local pwd="${PWD/#$HOME/~}" 16 | 17 | if [[ "$pwd" == (#m)[/~] ]]; then 18 | _prompt_sorin_pwd="$MATCH" 19 | unset MATCH 20 | else 21 | _prompt_sorin_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}" 22 | fi 23 | } 24 | 25 | function prompt_sorin_precmd { 26 | setopt LOCAL_OPTIONS 27 | unsetopt XTRACE KSH_ARRAYS 28 | 29 | # Format PWD. 30 | prompt_sorin_pwd 31 | 32 | # Get Git repository information. 33 | if (( $+functions[git-info] )); then 34 | git-info 35 | fi 36 | } 37 | 38 | function prompt_sorin_setup { 39 | setopt LOCAL_OPTIONS 40 | unsetopt XTRACE KSH_ARRAYS 41 | prompt_opts=(cr percent subst) 42 | 43 | # Load required functions. 44 | autoload -Uz add-zsh-hook 45 | 46 | # Add hook for calling git-info before each command. 47 | add-zsh-hook precmd prompt_sorin_precmd 48 | 49 | # Set editor-info parameters. 50 | zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' 51 | zstyle ':prezto:module:editor:info:keymap:primary' format ' %B%F{red}❯%F{yellow}❯%F{green}❯%f%b' 52 | zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f' 53 | zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{green}❮%F{yellow}❮%F{red}❮%f%b' 54 | 55 | # Set git-info parameters. 56 | zstyle ':prezto:module:git:info' verbose 'yes' 57 | zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b' 58 | zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b' 59 | zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b' 60 | zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b' 61 | zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f' 62 | zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f' 63 | zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b' 64 | zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b' 65 | zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f' 66 | zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b' 67 | zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b' 68 | zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b' 69 | zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b' 70 | zstyle ':prezto:module:git:info:keys' format \ 71 | 'prompt' ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s' \ 72 | 'rprompt' '%A%B%S%a%d%m%r%U%u' 73 | 74 | # Define prompts. 75 | PROMPT='%F{cyan}${_prompt_sorin_pwd}%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} ' 76 | RPROMPT='${editor_info[overwrite]}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}' 77 | SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' 78 | } 79 | 80 | prompt_sorin_setup "$@" 81 | 82 | -------------------------------------------------------------------------------- /modules/python/README.md: -------------------------------------------------------------------------------- 1 | Python 2 | ====== 3 | 4 | Enables local Python and local Python package installation. 5 | 6 | Local Python Installation 7 | ------------------------- 8 | 9 | [pyenv][4] builds and installs multiple Python versions locally in the home 10 | directory. 11 | 12 | This module prepends the pyenv directory to the path variable to enable the 13 | execution of `pyenv`. 14 | 15 | ### Usage 16 | 17 | Install Python versions with `pyenv install` into *~/.pyenv/versions*. 18 | 19 | Local Package Installation 20 | -------------------------- 21 | 22 | Since version 2.6, Python supports per user package installation, as defined in 23 | [PEP 370][1]. 24 | 25 | This module prepends per user site directories to the relevant path variables 26 | to enable the execution of user installed scripts and the reading of 27 | documentation. 28 | 29 | ### Usage 30 | 31 | Install packages into the per user site directory with `easy_install --user` or 32 | `pip install --user`. 33 | 34 | virtualenvwrapper 35 | ----------------- 36 | 37 | [virtualenvwrapper][2] is a frontend to the popular [virtualenv][3] utility. 38 | 39 | virtualenv creates isolated Python environments and virtualenvwrapper provides 40 | convenient shell functions to create, switch, and manage them. 41 | 42 | ### Usage 43 | 44 | Install virtualenvwrapper. 45 | 46 | Virtual environments are stored in *~/.virtualenvs*. 47 | 48 | There are configuration variables that have to be set to enable certain features. 49 | If you wish to use these features, export the variables in *~/.zshenv* 50 | 51 | The variable `$PROJECT_HOME` tells virtualenvwrapper where to place project 52 | working directories. It must be set and the directory created before `mkproject` 53 | is used. Replace *Developer* with your projects directory. 54 | 55 | export PROJECT_HOME="$HOME/Developer" 56 | 57 | The variable `$VIRTUALENVWRAPPER_VIRTUALENV_ARGS` tells virtualenvwrapper what 58 | arguments to pass to `virtualenv`. For example, set the value to 59 | *--no-site-packages* to ensure that all new environments are isolated from the 60 | system site-packages directory. 61 | 62 | export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' 63 | 64 | Aliases 65 | ------- 66 | 67 | - `py` is short for `python`. 68 | 69 | Functions 70 | --------- 71 | 72 | - `python-info` exposes information about the Python environment via the 73 | `$python_info` associative array. 74 | 75 | Theming 76 | ------- 77 | 78 | To display the name of the current virtual enviroment in a prompt, define the 79 | following style in the `prompt_name_setup` function. 80 | 81 | # %v - virtualenv name. 82 | zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v' 83 | 84 | Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call 85 | `python-info` in the `prompt_name_preexec` hook function. 86 | 87 | Authors 88 | ------- 89 | 90 | *The authors of this module should be contacted via the [issue tracker][5].* 91 | 92 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 93 | - [Sebastian Wiesner](https://github.com/lunaryorn) 94 | 95 | [1]: http://www.python.org/dev/peps/pep-0370/ 96 | [2]: http://www.doughellmann.com/projects/virtualenvwrapper/ 97 | [3]: http://pypi.python.org/pypi/virtualenv 98 | [4]: https://github.com/yyuu/pyenv 99 | [5]: https://github.com/sorin-ionescu/prezto/issues 100 | 101 | -------------------------------------------------------------------------------- /init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Initializes Prezto. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # Version Check 10 | # 11 | 12 | # Check for the minimum supported version. 13 | min_zsh_version='4.3.11' 14 | if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then 15 | print "prezto: old shell detected, minimum required: $min_zsh_version" >&2 16 | return 1 17 | fi 18 | unset min_zsh_version 19 | 20 | # 21 | # Module Loader 22 | # 23 | 24 | # Loads Prezto modules. 25 | function pmodload { 26 | local -a pmodules 27 | local pmodule 28 | local pfunction_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)' 29 | 30 | # $argv is overridden in the anonymous function. 31 | pmodules=("$argv[@]") 32 | 33 | # Add functions to $fpath. 34 | fpath=(${pmodules:+${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions(/FN)} $fpath) 35 | 36 | function { 37 | local pfunction 38 | 39 | # Extended globbing is needed for listing autoloadable function directories. 40 | setopt LOCAL_OPTIONS EXTENDED_GLOB 41 | 42 | # Load Prezto functions. 43 | for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions/$~pfunction_glob; do 44 | autoload -Uz "$pfunction" 45 | done 46 | } 47 | 48 | # Load Prezto modules. 49 | for pmodule in "$pmodules[@]"; do 50 | if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then 51 | continue 52 | elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then 53 | print "$0: no such module: $pmodule" >&2 54 | continue 55 | else 56 | if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" ]]; then 57 | source "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" 58 | fi 59 | 60 | if (( $? == 0 )); then 61 | zstyle ":prezto:module:$pmodule" loaded 'yes' 62 | else 63 | # Remove the $fpath entry. 64 | fpath[(r)${ZDOTDIR:-$HOME}/.zprezto/modules/${pmodule}/functions]=() 65 | 66 | function { 67 | local pfunction 68 | 69 | # Extended globbing is needed for listing autoloadable function 70 | # directories. 71 | setopt LOCAL_OPTIONS EXTENDED_GLOB 72 | 73 | # Unload Prezto functions. 74 | for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/functions/$~pfunction_glob; do 75 | unfunction "$pfunction" 76 | done 77 | } 78 | 79 | zstyle ":prezto:module:$pmodule" loaded 'no' 80 | fi 81 | fi 82 | done 83 | } 84 | 85 | # 86 | # Prezto Initialization 87 | # 88 | 89 | # Source the Prezto configuration file. 90 | if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then 91 | source "${ZDOTDIR:-$HOME}/.zpreztorc" 92 | fi 93 | 94 | # Disable color and theme in dumb terminals. 95 | if [[ "$TERM" == 'dumb' ]]; then 96 | zstyle ':prezto:*:*' color 'no' 97 | zstyle ':prezto:module:prompt' theme 'off' 98 | fi 99 | 100 | # Load Zsh modules. 101 | zstyle -a ':prezto:load' zmodule 'zmodules' 102 | for zmodule ("$zmodules[@]") zmodload "zsh/${(z)zmodule}" 103 | unset zmodule{s,} 104 | 105 | # Autoload Zsh functions. 106 | zstyle -a ':prezto:load' zfunction 'zfunctions' 107 | for zfunction ("$zfunctions[@]") autoload -Uz "$zfunction" 108 | unset zfunction{s,} 109 | 110 | # Load Prezto modules. 111 | zstyle -a ':prezto:load' pmodule 'pmodules' 112 | pmodload "$pmodules[@]" 113 | unset pmodules 114 | 115 | -------------------------------------------------------------------------------- /modules/ruby/README.md: -------------------------------------------------------------------------------- 1 | Ruby 2 | ==== 3 | 4 | Configures [Ruby][1] local gem installation, loads version managers, and defines 5 | aliases. 6 | 7 | Local Gem Installation 8 | ---------------------- 9 | 10 | When a Ruby version manager is not detected, local gems are installed in 11 | *~/.gems*; otherwise, they are installed according to the manager. 12 | 13 | RVM 14 | --- 15 | 16 | An alternative to the above is to use [The Ruby Version Manager (RVM)][2], which 17 | allows for managing multiple, isolated Ruby installations and gem sets in the 18 | home directory. 19 | 20 | Since RVM is loaded into the shell and is known to override shell commands, it 21 | may conflict with shell scripts. 22 | 23 | Load this module as late as possible when using RVM since RVM will complain if 24 | it is not first in `$PATH`. 25 | 26 | rbenv 27 | ----- 28 | 29 | An alternative RVM is to use [rbenv][3], which allows for switching between 30 | multiple, isolated Ruby installations in the home directory. 31 | 32 | While it is not as feature rich as RVM, it is not loaded into the shell and is 33 | not known to cause conflicts with shell scripts. 34 | 35 | chruby 36 | ------ 37 | 38 | Yet another alternative is [chruby][6], which is simpler than both RVM and 39 | rbenv. 40 | 41 | ### Settings 42 | 43 | #### Auto-Switch 44 | 45 | To enable auto switching the Ruby version on directory change based on the 46 | .ruby-version file, add the following line to *zpreztorc*: 47 | 48 | zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' 49 | 50 | Bundler 51 | ------- 52 | 53 | Manage gems that are not meant to be used as commands, such as application 54 | dependencies, with [Bundler][4]. 55 | 56 | Aliases 57 | ------- 58 | 59 | ### General 60 | 61 | - `rb` is short for `ruby`. 62 | 63 | ### Bundler 64 | 65 | - `rbb` manages ruby dependencies (`bundle`). 66 | - `rbbe` executes a script in the context of the current bundle. 67 | - `rbbi` installs the gems specified in the *Gemfile* in *vendor/bundle*. 68 | - `rbbI` installs the following: 69 | - gems specified in the *Gemfile* in *vendor/bundle*. 70 | - packages the gems into *vendor/cache*. 71 | - appends bundler directories to *.gitignore*. 72 | - `rbbl` lists all gems in the current bundle. 73 | - `rbbo` opens an installed gem in the editor. 74 | - `rbbp` packages gem files into *vendor/cache*. 75 | - `rbbu` updates gems to their latest version. 76 | 77 | Functions 78 | --------- 79 | 80 | - `ruby-app-root` displays the path to the Ruby application root directory. 81 | - `ruby-info` exposes information about the Ruby environment via the 82 | `$ruby_info` associative array. 83 | 84 | Theming 85 | ------- 86 | 87 | To display the name of the current Ruby version in a prompt, define the 88 | following style in the `prompt_name_setup` function. 89 | 90 | # %v - ruby version. 91 | zstyle ':prezto:module:ruby:info:version' format 'version:%v' 92 | 93 | Then add `$ruby_info[version]` to `$PROMPT` or `$RPROMPT` and call 94 | `ruby-info` in the `prompt_name_preexec` hook function. 95 | 96 | Authors 97 | ------- 98 | 99 | *The authors of this module should be contacted via the [issue tracker][5].* 100 | 101 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 102 | 103 | [1]: http://www.ruby-lang.org 104 | [2]: https://rvm.io 105 | [3]: https://github.com/sstephenson/rbenv 106 | [4]: http://gembundler.com 107 | [5]: https://github.com/sorin-ionescu/prezto/issues 108 | [6]: https://github.com/postmodern/chruby 109 | -------------------------------------------------------------------------------- /modules/spectrum/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Provides for easier use of 256 colors and effects. 3 | # 4 | # Authors: 5 | # P.C. Shyamshankar 6 | # Sorin Ionescu 7 | # 8 | 9 | # Return if requirements are not found. 10 | if [[ "$TERM" == 'dumb' ]]; then 11 | return 1 12 | fi 13 | 14 | typeset -gA FX FG BG 15 | 16 | FX=( 17 | none "\e[00m" 18 | normal "\e[22m" 19 | bold "\e[01m" no-bold "\e[22m" 20 | faint "\e[02m" no-faint "\e[22m" 21 | standout "\e[03m" no-standout "\e[23m" 22 | underline "\e[04m" no-underline "\e[24m" 23 | blink "\e[05m" no-blink "\e[25m" 24 | fast-blink "\e[06m" no-fast-blink "\e[25m" 25 | reverse "\e[07m" no-reverse "\e[27m" 26 | conceal "\e[08m" no-conceal "\e[28m" 27 | strikethrough "\e[09m" no-strikethrough "\e[29m" 28 | gothic "\e[20m" no-gothic "\e[22m" 29 | double-underline "\e[21m" no-double-underline "\e[22m" 30 | proportional "\e[26m" no-proportional "\e[50m" 31 | overline "\e[53m" no-overline "\e[55m" 32 | 33 | no-border "\e[54m" 34 | border-rectangle "\e[51m" no-border-rectangle "\e[54m" 35 | border-circle "\e[52m" no-border-circle "\e[54m" 36 | 37 | no-ideogram-marking "\e[65m" 38 | underline-or-right "\e[60m" no-underline-or-right "\e[65m" 39 | double-underline-or-right "\e[61m" no-double-underline-or-right "\e[65m" 40 | overline-or-left "\e[62m" no-overline-or-left "\e[65m" 41 | double-overline-or-left "\e[63m" no-double-overline-or-left "\e[65m" 42 | stress "\e[64m" no-stress "\e[65m" 43 | 44 | font-default "\e[10m" 45 | font-first "\e[11m" no-font-first "\e[10m" 46 | font-second "\e[12m" no-font-second "\e[10m" 47 | font-third "\e[13m" no-font-third "\e[10m" 48 | font-fourth "\e[14m" no-font-fourth "\e[10m" 49 | font-fifth "\e[15m" no-font-fifth "\e[10m" 50 | font-sixth "\e[16m" no-font-sixth "\e[10m" 51 | font-seventh "\e[17m" no-font-seventh "\e[10m" 52 | font-eigth "\e[18m" no-font-eigth "\e[10m" 53 | font-ninth "\e[19m" no-font-ninth "\e[10m" 54 | ) 55 | 56 | FG[none]="$FX[none]" 57 | BG[none]="$FX[none]" 58 | colors=(black red green yellow blue magenta cyan white) 59 | for color in {0..255}; do 60 | if (( $color >= 0 )) && (( $color < $#colors )); then 61 | index=$(( $color + 1 )) 62 | FG[$colors[$index]]="\e[38;5;${color}m" 63 | BG[$colors[$index]]="\e[48;5;${color}m" 64 | fi 65 | 66 | FG[$color]="\e[38;5;${color}m" 67 | BG[$color]="\e[48;5;${color}m" 68 | done 69 | unset color{s,} index 70 | 71 | -------------------------------------------------------------------------------- /modules/prompt/README.md: -------------------------------------------------------------------------------- 1 | Prompt 2 | ====== 3 | 4 | Loads prompt [themes][1]. 5 | 6 | Settings 7 | -------- 8 | 9 | To select a prompt theme, add the following to *zpreztorc*, and replace **name** 10 | with the name of the theme you wish to load. Setting it to **random** will load 11 | a random theme. 12 | 13 | zstyle ':prezto:module:prompt' theme 'name' 14 | 15 | Theming 16 | ------- 17 | 18 | A prompt theme is an autoloadable function file with a special name, 19 | `prompt_name_setup`, placed anywhere in `$fpath`, but for the purpose of this 20 | project, themes **should** be placed in the *modules/prompt/functions* 21 | directory. 22 | 23 | ### Theme Functions 24 | 25 | There are three theme functions, a setup function, a help function, and 26 | a preview function. The setup function **must** always be defined. The help 27 | function and the preview functions are optional. 28 | 29 | #### prompt_name_setup 30 | 31 | This function is called by the `prompt` function to install the theme. This 32 | function may define other functions as necessary to maintain the prompt, 33 | including a function that displays help or a function used to preview it. 34 | 35 | **Do not call this function directly.** 36 | 37 | The most basic example of this function can be seen below. 38 | 39 | function prompt_name_setup { 40 | PROMPT='%m%# ' 41 | RPROMPT='' 42 | } 43 | 44 | #### prompt_name_help 45 | 46 | If the `prompt_name_setup` function is customizable via parameters, a help 47 | function **should** be defined. The user will access it via `prompt -h name`. 48 | 49 | The most basic example of this function can be seen bellow. 50 | 51 | function prompt_name_help { 52 | cat <] [] 56 | 57 | where the color is for the left-hand prompt. 58 | EOH 59 | } 60 | 61 | #### prompt_name_preview 62 | 63 | If the `prompt_name_setup` function is customizable via parameters, a preview 64 | function **should** be defined. The user will access it via `prompt -p name`. 65 | 66 | The most basic example of this function can be seen bellow. 67 | 68 | function prompt_name_preview { 69 | if (( $# > 0 )); then 70 | prompt_preview_theme theme "$@" 71 | else 72 | prompt_preview_theme theme red green blue 73 | print 74 | prompt_preview_theme theme yellow magenta black 75 | fi 76 | } 77 | 78 | ### Hook Functions 79 | 80 | There are many Zsh [hook][2] functions, but mostly the *precmd* hook will be 81 | used. 82 | 83 | #### prompt_name_precmd 84 | 85 | This hook is called before the prompt is displayed and is useful for getting 86 | information to display in a prompt. 87 | 88 | When calling functions to get information to display in a prompt, do not assume 89 | that all the dependencies have been loaded. Always check for the availability of 90 | a function before you calling it. 91 | 92 | **Do not register hook functions. They will be registered by the `prompt` function.** 93 | 94 | The most basic example of this function can be seen bellow. 95 | 96 | function prompt_name_precmd { 97 | if (( $+functions[git-info] )); then 98 | git-info 99 | fi 100 | } 101 | 102 | Authors 103 | ------- 104 | 105 | *The authors of this module should be contacted via the [issue tracker][3].* 106 | 107 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 108 | 109 | [1]: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Prompt-Themes 110 | [2]: http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions 111 | [3]: https://github.com/sorin-ionescu/prezto/issues 112 | 113 | -------------------------------------------------------------------------------- /modules/spectrum/README.md: -------------------------------------------------------------------------------- 1 | Spectrum 2 | ======== 3 | 4 | Provides for easier use of 256 colors and effects. 5 | 6 | To learn more about text formatting, read [That 256 Color Thing][1]. 7 | 8 | Variables 9 | --------- 10 | 11 | - `BG` provides background colors. 12 | - `FG` provides foreground colors. 13 | - `FX` provides effects. 14 | 15 | ### Background and Foreground 16 | 17 | Terminals support 8, 16, 88, and 256 colors. Check if a terminal supports 256 18 | colors with `tput colors` before use. 19 | 20 | The following colors are supported. 21 | 22 | - 0 to 255 23 | - black 24 | - red 25 | - green 26 | - yellow 27 | - blue 28 | - magenta 29 | - cyan 30 | - white 31 | 32 | ### Effects 33 | 34 | Though there are many effects, most terminals support at least bold formatting. 35 | 36 | **Not all effects work on all terminals; use them sparingly.** 37 | 38 | | Enable | Disable | 39 | | ------------------------- | ---------------------------- | 40 | | | none | 41 | | | normal | 42 | | bold | no-bold | 43 | | faint | no-faint | 44 | | standout | no-standout | 45 | | underline | no-underline | 46 | | blink | no-blink | 47 | | fast-blink | no-fast-blink | 48 | | reverse | no-reverse | 49 | | conceal | no-conceal | 50 | | strikethrough | no-strikethrough | 51 | | gothic | no-gothic | 52 | | double-underline | no-double-underline | 53 | | proportional | no-proportional | 54 | | overline | no-overline | 55 | | | | 56 | | | no-border | 57 | | border-rectangle | no-border-rectangle | 58 | | border-circle | no-border-circle | 59 | | | | 60 | | | no-ideogram-marking | 61 | | underline-or-right | no-underline-or-right | 62 | | double-underline-or-right | no-double-underline-or-right | 63 | | overline-or-left | no-overline-or-left | 64 | | double-overline-or-left | no-double-overline-or-left | 65 | | stress | no-stress | 66 | | | | 67 | | | font-default | 68 | | font-first | no-font-first | 69 | | font-second | no-font-second | 70 | | font-third | no-font-third | 71 | | font-fourth | no-font-fourth | 72 | | font-fifth | no-font-fifth | 73 | | font-sixth | no-font-sixth | 74 | | font-seventh | no-font-seventh | 75 | | font-eigth | no-font-eigth | 76 | | font-ninth | no-font-ninth | 77 | 78 | ### Plain Text 79 | 80 | Use `$BG[none]`, `$FG[none]`, or `$FX[none]` to turn off formatting. 81 | 82 | Authors 83 | ------- 84 | 85 | *The authors of this module should be contacted via the [issue tracker][2].* 86 | 87 | - [P.C. Shyamshankar](https://github.com/sykora) 88 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 89 | 90 | [1]: http://lucentbeing.com/blog/that-256-color-thing/ 91 | [2]: https://github.com/sorin-ionescu/prezto/issues 92 | 93 | -------------------------------------------------------------------------------- /modules/README.md: -------------------------------------------------------------------------------- 1 | Modules 2 | ======= 3 | 4 | Load modules in *zpreztorc*. The order matters. 5 | 6 | zstyle ':prezto:load' pmodule 'environment' 'terminal' 7 | 8 | Archive 9 | ------- 10 | 11 | Provides functions to list and extract archives. 12 | 13 | Command-Not-Found 14 | ----------------- 15 | 16 | Loads the command-not-found tool on Debian-based distributions. 17 | 18 | Completion 19 | ---------- 20 | 21 | Loads and configures tab completion and provides additional completions from 22 | the zsh-completions project. 23 | 24 | Directory 25 | --------- 26 | 27 | Sets directory options and defines directory aliases. 28 | 29 | Dpkg 30 | ---- 31 | 32 | Defines dpkg aliases and functions. 33 | 34 | Editor 35 | ------ 36 | 37 | Sets key bindings. 38 | 39 | Emacs 40 | ----- 41 | 42 | Enables Emacs dependency management. 43 | 44 | Environment 45 | ----------- 46 | 47 | Sets general shell options and defines environment variables. 48 | 49 | Fasd 50 | ---- 51 | 52 | Maintains a frequently used file and directory list for fast access. 53 | 54 | Git 55 | --- 56 | 57 | Enhances the Git distributed version control system by providing aliases, 58 | functions and by exposing repository status information to prompts. 59 | 60 | GNU Utility 61 | ----------- 62 | 63 | Provides for the interactive use of GNU utilities on non-GNU systems. 64 | 65 | GPG 66 | --- 67 | 68 | Provides for an easier use of GPG by setting up gpg-agent. 69 | 70 | Haskell 71 | ------- 72 | 73 | Enables local Haskell package installation. 74 | 75 | Helper 76 | ------ 77 | 78 | Provides helper functions for developing modules. 79 | 80 | History 81 | ------- 82 | 83 | Sets history options and defines history aliases. 84 | 85 | History Substring Search 86 | ------------------------ 87 | 88 | Integrates zsh-history-substring-search into Prezto. 89 | 90 | Homebrew 91 | -------- 92 | 93 | Defines Homebrew aliases. 94 | 95 | Macports 96 | -------- 97 | 98 | Defines MacPorts aliases and adds MacPorts directories to path variables. 99 | 100 | Node.js 101 | ------- 102 | 103 | Provides utility functions for Node.js and loads npm completion. 104 | 105 | Ocaml 106 | ----- 107 | 108 | Initializes Ocaml package management. 109 | 110 | OSX 111 | --- 112 | 113 | Defines Mac OS X aliases and functions. 114 | 115 | Pacman 116 | ------ 117 | 118 | Provides aliases and functions for the Pacman package manager and frontends. 119 | 120 | Perl 121 | ---- 122 | 123 | Enables local Perl module installation on Mac OS X and defines alises. 124 | 125 | Prompt 126 | ------ 127 | 128 | Loads prompt themes. 129 | 130 | Python 131 | ------ 132 | 133 | Enables local Python and local Python package installation. 134 | 135 | Ruby on Rails 136 | ------------- 137 | 138 | Defines Ruby on Rails aliases. 139 | 140 | Rsync 141 | ----- 142 | 143 | Defines rsync aliases. 144 | 145 | Ruby 146 | ---- 147 | 148 | Configures Ruby local gem installation, loads version managers, and defines 149 | aliases. 150 | 151 | GNU Screen 152 | ---------- 153 | 154 | Defines GNU Screen aliases and provides for auto launching it at start-up. 155 | 156 | Spectrum 157 | -------- 158 | 159 | Provides for easier use of 256 colors and effects. 160 | 161 | SSH 162 | --- 163 | 164 | Provides for an easier use of SSH by setting up ssh-agent. 165 | 166 | Syntax Highlighting 167 | ------------------- 168 | 169 | Integrates zsh-syntax-highlighting into Prezto. 170 | 171 | Terminal 172 | -------- 173 | 174 | Sets terminal window and tab titles. 175 | 176 | Tmux 177 | ---- 178 | 179 | Defines tmux aliases and provides for auto launching it at start-up. 180 | 181 | Utility 182 | ------- 183 | 184 | Defines general aliases and functions. 185 | 186 | Wake-on-LAN 187 | ----------- 188 | 189 | This module provides a wrapper around the wakeonlan tool. 190 | 191 | Yum 192 | --- 193 | 194 | Defines yum aliases. 195 | 196 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Prezto — Instantly Awesome Zsh 2 | ============================== 3 | 4 | Prezto is the configuration framework for [Zsh][1]; it enriches the command line 5 | interface environment with sane defaults, aliases, functions, auto completion, 6 | and prompt themes. 7 | 8 | Installation 9 | ------------ 10 | 11 | Prezto will work with any recent release of Zsh, but the minimum recommended 12 | version is 4.3.11. 13 | 14 | 1. Launch Zsh: 15 | 16 | zsh 17 | 18 | 2. Clone the repository: 19 | 20 | git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" 21 | 22 | 3. Create a new Zsh configuration by copying the Zsh configuration files 23 | provided: 24 | 25 | setopt EXTENDED_GLOB 26 | for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do 27 | ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" 28 | done 29 | 30 | 4. Set Zsh as your default shell: 31 | 32 | chsh -s /bin/zsh 33 | 34 | 5. Open a new Zsh terminal window or tab. 35 | 36 | ### Troubleshooting 37 | 38 | If you are not able to find certain commands after switching to *Prezto*, 39 | modify the `PATH` variable in *~/.zprofile* then open a new Zsh terminal 40 | window or tab. 41 | 42 | Updating 43 | -------- 44 | 45 | Pull the latest changes and update submodules. 46 | 47 | git pull && git submodule update --init --recursive 48 | 49 | Usage 50 | ----- 51 | 52 | Prezto has many features disabled by default. Read the source code and 53 | accompanying README files to learn of what is available. 54 | 55 | ### Modules 56 | 57 | 1. Browse */modules* to see what is available. 58 | 2. Load the modules you need in *~/.zpreztorc* then open a new Zsh terminal 59 | window or tab. 60 | 61 | ### Themes 62 | 63 | 1. For a list of themes, type `prompt -l`. 64 | 2. To preview a theme, type `prompt -p name`. 65 | 3. Load the theme you like in *~/.zpreztorc* then open a new Zsh terminal 66 | window or tab. 67 | 68 | ![sorin theme][2] 69 | 70 | Customization 71 | ------------- 72 | 73 | The project is managed via [Git][3]. It is highly recommended that you fork this 74 | project; so, that you can commit your changes and push them to [GitHub][4] to 75 | not lose them. If you do not know how to use Git, follow this [tutorial][5] and 76 | bookmark this [reference][6]. 77 | 78 | Resources 79 | --------- 80 | 81 | The [Zsh Reference Card][7] and the [zsh-lovers][8] man page are indispensable. 82 | 83 | License 84 | ------- 85 | 86 | (The MIT License) 87 | 88 | Copyright (c) 2009-2011 Robby Russell and contributors. 89 | Copyright (c) 2011-2014 Sorin Ionescu and contributors. 90 | 91 | Permission is hereby granted, free of charge, to any person obtaining a copy of 92 | this software and associated documentation files (the "Software"), to deal in 93 | the Software without restriction, including without limitation the rights to 94 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 95 | of the Software, and to permit persons to whom the Software is furnished to do 96 | so, subject to the following conditions: 97 | 98 | The above copyright notice and this permission notice shall be included in all 99 | copies or substantial portions of the Software. 100 | 101 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 102 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 103 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 104 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 105 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 106 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 107 | SOFTWARE. 108 | 109 | [1]: http://www.zsh.org 110 | [2]: http://i.imgur.com/nBEEZ.png "sorin theme" 111 | [3]: http://git-scm.com 112 | [4]: https://github.com 113 | [5]: http://gitimmersion.com 114 | [6]: http://gitref.org 115 | [7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf 116 | [8]: http://grml.org/zsh/zsh-lovers.html 117 | 118 | -------------------------------------------------------------------------------- /runcoms/zpreztorc: -------------------------------------------------------------------------------- 1 | # 2 | # Sets Prezto options. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # General 10 | # 11 | 12 | # Set case-sensitivity for completion, history lookup, etc. 13 | # zstyle ':prezto:*:*' case-sensitive 'yes' 14 | 15 | # Color output (auto set to 'no' on dumb terminals). 16 | zstyle ':prezto:*:*' color 'yes' 17 | 18 | # Set the Zsh modules to load (man zshmodules). 19 | # zstyle ':prezto:load' zmodule 'attr' 'stat' 20 | 21 | # Set the Zsh functions to load (man zshcontrib). 22 | # zstyle ':prezto:load' zfunction 'zargs' 'zmv' 23 | 24 | # Set the Prezto modules to load (browse modules). 25 | # The order matters. 26 | zstyle ':prezto:load' pmodule \ 27 | 'environment' \ 28 | 'terminal' \ 29 | 'editor' \ 30 | 'history' \ 31 | 'homebrew' \ 32 | 'directory' \ 33 | 'osx' \ 34 | 'spectrum' \ 35 | 'utility' \ 36 | 'completion' \ 37 | 'ruby' \ 38 | 'git' \ 39 | 'syntax-highlighting' \ 40 | 'history-substring-search' \ 41 | 'prompt' 42 | 43 | # 44 | # Editor 45 | # 46 | # 47 | 48 | # Set the key mapping style to 'emacs' or 'vi'. 49 | zstyle ':prezto:module:editor' key-bindings 'vi' 50 | 51 | # Auto convert .... to ../.. 52 | # zstyle ':prezto:module:editor' dot-expansion 'yes' 53 | 54 | # 55 | # Git 56 | # 57 | 58 | # Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. 59 | zstyle ':prezto:module:git:status:ignore' submodules 'all' 60 | 61 | # 62 | # GNU Utility 63 | # 64 | 65 | # Set the command prefix on non-GNU systems. 66 | # zstyle ':prezto:module:gnu-utility' prefix 'g' 67 | 68 | # 69 | # History Substring Search 70 | # 71 | 72 | # Set the query found color. 73 | zstyle ':prezto:module:history-substring-search:color' found '' 74 | 75 | # Set the query not found color. 76 | zstyle ':prezto:module:history-substring-search:color' not-found '' 77 | 78 | # Set the search globbing flags. 79 | zstyle ':prezto:module:history-substring-search' globbing-flags '' 80 | 81 | # 82 | # Pacman 83 | # 84 | 85 | # Set the Pacman frontend. 86 | # zstyle ':prezto:module:pacman' frontend 'yaourt' 87 | 88 | # 89 | # Prompt 90 | # 91 | 92 | # Set the prompt theme to load. 93 | # Setting it to 'random' loads a random theme. 94 | # Auto set to 'off' on dumb terminals. 95 | zstyle ':prezto:module:prompt' theme 'jason' 96 | 97 | # 98 | # Ruby 99 | # 100 | 101 | # Auto switch the Ruby version on directory change. 102 | zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' 103 | 104 | # 105 | # Screen 106 | # 107 | 108 | # Auto start a session when Zsh is launched in a local terminal. 109 | # zstyle ':prezto:module:screen:auto-start' local 'yes' 110 | 111 | # Auto start a session when Zsh is launched in a SSH connection. 112 | # zstyle ':prezto:module:screen:auto-start' remote 'yes' 113 | 114 | # 115 | # SSH 116 | # 117 | 118 | # Set the SSH identities to load into the agent. 119 | # zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github' 120 | 121 | # 122 | # Syntax Highlighting 123 | # 124 | 125 | # Set syntax highlighters. 126 | # By default, only the main highlighter is enabled. 127 | # zstyle ':prezto:module:syntax-highlighting' highlighters \ 128 | # 'main' \ 129 | # 'brackets' \ 130 | # 'pattern' \ 131 | # 'cursor' \ 132 | # 'root' 133 | # 134 | # Set syntax highlighting styles. 135 | # zstyle ':prezto:module:syntax-highlighting' styles \ 136 | # 'builtin' 'bg=blue' \ 137 | # 'command' 'bg=blue' \ 138 | # 'function' 'bg=blue' 139 | 140 | # 141 | # Terminal 142 | # 143 | 144 | # Auto set the tab and window titles. 145 | # zstyle ':prezto:module:terminal' auto-title 'yes' 146 | 147 | # Set the window title format. 148 | # zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' 149 | 150 | # Set the tab title format. 151 | # zstyle ':prezto:module:terminal:tab-title' format '%m: %s' 152 | 153 | # 154 | # Tmux 155 | # 156 | 157 | # Auto start a session when Zsh is launched in a local terminal. 158 | # zstyle ':prezto:module:tmux:auto-start' local 'yes' 159 | 160 | # Auto start a session when Zsh is launched in a SSH connection. 161 | # zstyle ':prezto:module:tmux:auto-start' remote 'yes' 162 | -------------------------------------------------------------------------------- /modules/terminal/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets terminal window and tab titles. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if [[ "$TERM" == (dumb|linux|*bsd*) ]]; then 10 | return 1 11 | fi 12 | 13 | # Sets the terminal or terminal multiplexer window title. 14 | function set-window-title { 15 | local title_format{,ted} 16 | zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s" 17 | zformat -f title_formatted "$title_format" "s:$argv" 18 | 19 | if [[ "$TERM" == screen* ]]; then 20 | title_format="\ek%s\e\\" 21 | else 22 | title_format="\e]2;%s\a" 23 | fi 24 | 25 | printf "$title_format" "${(V%)title_formatted}" 26 | } 27 | 28 | # Sets the terminal tab title. 29 | function set-tab-title { 30 | local title_format{,ted} 31 | zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s" 32 | zformat -f title_formatted "$title_format" "s:$argv" 33 | 34 | printf "\e]1;%s\a" ${(V%)title_formatted} 35 | } 36 | 37 | # Sets the tab and window titles with a given command. 38 | function _terminal-set-titles-with-command { 39 | emulate -L zsh 40 | setopt EXTENDED_GLOB 41 | 42 | # Get the command name that is under job control. 43 | if [[ "${2[(w)1]}" == (fg|%*)(\;|) ]]; then 44 | # Get the job name, and, if missing, set it to the default %+. 45 | local job_name="${${2[(wr)%*(\;|)]}:-%+}" 46 | 47 | # Make a local copy for use in the subshell. 48 | local -A jobtexts_from_parent_shell 49 | jobtexts_from_parent_shell=(${(kv)jobtexts}) 50 | 51 | jobs "$job_name" 2>/dev/null > >( 52 | read index discarded 53 | # The index is already surrounded by brackets: [1]. 54 | _terminal-set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" 55 | ) 56 | else 57 | # Set the command name, or in the case of sudo or ssh, the next command. 58 | local cmd="${${2[(wr)^(*=*|sudo|ssh|-*)]}:t}" 59 | local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}" 60 | unset MATCH 61 | 62 | set-window-title "$cmd" 63 | set-tab-title "$truncated_cmd" 64 | fi 65 | } 66 | 67 | # Sets the tab and window titles with a given path. 68 | function _terminal-set-titles-with-path { 69 | emulate -L zsh 70 | setopt EXTENDED_GLOB 71 | 72 | local absolute_path="${${1:a}:-$PWD}" 73 | local abbreviated_path="${absolute_path/#$HOME/~}" 74 | local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" 75 | unset MATCH 76 | 77 | set-window-title "$abbreviated_path" 78 | set-tab-title "$truncated_path" 79 | } 80 | 81 | # Sets the Terminal.app proxy icon. 82 | function _terminal-set-terminal-app-proxy-icon { 83 | printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" 84 | } 85 | 86 | # Do not override precmd/preexec; append to the hook array. 87 | autoload -Uz add-zsh-hook 88 | 89 | # Set up the Apple Terminal. 90 | if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \ 91 | && ( ! [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] ) 92 | then 93 | # Sets the Terminal.app current working directory before the prompt is 94 | # displayed. 95 | add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon 96 | 97 | # Unsets the Terminal.app current working directory when a terminal 98 | # multiplexer or remote connection is started since it can no longer be 99 | # updated, and it becomes confusing when the directory displayed in the title 100 | # bar is no longer synchronized with real current working directory. 101 | function _terminal-unset-terminal-app-proxy-icon { 102 | if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then 103 | _terminal-set-terminal-app-proxy-icon ' ' 104 | fi 105 | } 106 | add-zsh-hook preexec _terminal-unset-terminal-app-proxy-icon 107 | 108 | # Do not set the tab and window titles in Terminal.app since it sets the tab 109 | # title to the currently running process by default and the current working 110 | # directory is set separately. 111 | return 112 | fi 113 | 114 | # Set up non-Apple terminals. 115 | if zstyle -t ':prezto:module:terminal' auto-title \ 116 | && ( ! [[ -n "$STY" || -n "$TMUX" ]] ) 117 | then 118 | # Sets the tab and window titles before the prompt is displayed. 119 | add-zsh-hook precmd _terminal-set-titles-with-path 120 | 121 | # Sets the tab and window titles before command execution. 122 | add-zsh-hook preexec _terminal-set-titles-with-command 123 | fi 124 | 125 | -------------------------------------------------------------------------------- /modules/utility/README.md: -------------------------------------------------------------------------------- 1 | Utility 2 | ======= 3 | 4 | Defines general aliases and functions. 5 | 6 | Settings 7 | -------- 8 | 9 | ### Highlighting 10 | 11 | If you have enabled color globally in *zpreztorc*, you may disable it for certain 12 | commands. 13 | 14 | To disable `ls` color, add the following line to *zpreztorc*; when coloring is 15 | disabled, type indicators (\*, /, =>, @, =, |, %) will be appended to entries. 16 | 17 | zstyle ':prezto:module:utility:ls' color 'no' 18 | 19 | To disable `diff` highlighting, add the following line to *zpreztorc*: 20 | 21 | zstyle ':prezto:module:utility:diff' color 'no' 22 | 23 | To disable `wdiff` highlighting, add the following line to *zpreztorc*: 24 | 25 | zstyle ':prezto:module:utility:wdiff' color 'no' 26 | 27 | To disable `make` highlighting, add the following line to *zpreztorc*: 28 | 29 | zstyle ':prezto:module:utility:make' color 'no' 30 | 31 | Aliases 32 | ------- 33 | 34 | ### Disabled Spelling Correction 35 | 36 | - `ack` 37 | - `cd` 38 | - `cp` 39 | - `ebuild` 40 | - `gcc` 41 | - `gist` 42 | - `grep` 43 | - `heroku` 44 | - `ln` 45 | - `man` 46 | - `mkdir` 47 | - `mv` 48 | - `mysql` 49 | - `rm` 50 | 51 | ### Disabled File Globbing 52 | 53 | - `bower` 54 | - `fc` 55 | - `find` 56 | - `ftp` 57 | - `history` 58 | - `locate` 59 | - `rake` 60 | - `rsync` 61 | - `scp` 62 | - `sftp` 63 | 64 | ### General 65 | 66 | - `_` executes a command as another user (`sudo`). 67 | - `b` opens the default web browser. 68 | - `cp` copies files and directories interactively. 69 | - `e` opens the default editor. 70 | - `ln` links files and directories interactively. 71 | - `mkdir` creates directories, including intermediary directories. 72 | - `mv` moves files and directories interactively. 73 | - `p` opens the default pager. 74 | - `po` removes a directory from the stack and changes to it (`popd`). 75 | - `pu` changes the directory and pushes the old directory onto the stack 76 | (`pushd`). 77 | - `rm` removes files and directories interactively. 78 | - `type` displays all the attribute values of a shell parameter. 79 | 80 | ### Files and Directories 81 | 82 | - `ls` lists with directories grouped first (GNU only). 83 | - `l` lists in one column, hidden files. 84 | - `ll` lists human readable sizes. 85 | - `lr` lists human readable sizes, recursively. 86 | - `la` lists human readable sizes, hidden files. 87 | - `lm` lists human readable sizes, hidden files through pager. 88 | - `lx` lists sorted by extension (GNU only). 89 | - `lk` lists sorted by size, largest last. 90 | - `lt` lists sorted by date, most recent last. 91 | - `lc` lists sorted by date, most recent last, shows change time. 92 | - `lu` lists sorted by date, most recent last, shows access time. 93 | - `sl` lists directory contents (`ls`). 94 | 95 | ### Mac OS X Everywhere 96 | 97 | - `o` opens files and directories (`open` or `xdg-open`). 98 | - `get` downloads files (`curl` or `wget`). 99 | - `pbcopy` copies to the pasteboard (`pbcopy`, `xclip` or `xsel`). 100 | - `pbpaste` pastes from the pasteboard (`pbcopy`, `xclip` or `xsel`). 101 | - `pbc` copies to the pasteboard (`pbcopy`). 102 | - `pbp` pastes from the pasteboard (`pbpaste`). 103 | 104 | ### Resource Usage 105 | 106 | - `df` displays free disk space using human readable units. 107 | - `du` displays disk usage using human readable units. 108 | - `top` displays information about processes (aliased to `htop`, if installed). 109 | - `topc` displays information about processes sorted by CPU usage (`htop` not 110 | installed). 111 | - `topm` displays information about processes sorted by RAM usage (`htop` not 112 | installed). 113 | 114 | ### Miscellaneous 115 | 116 | - `http-serve` serves a directory via HTTP. 117 | 118 | Functions 119 | --------- 120 | 121 | ### General 122 | 123 | - `slit` prints columns *1, 2, 3 ... n*. 124 | 125 | ### Files and Directories 126 | 127 | - `cdls` changes to a directory and lists its contents. 128 | - `dut` displays the grand total disk usage using human readable units. 129 | - `find-exec` finds files and executes a command on them. 130 | - `mkdcd` makes a directory and changes to it. 131 | - `popdls` pops an entry off the directory stack and lists its contents. 132 | - `pushdls` pushes an entry onto the directory stack and lists its contents. 133 | 134 | ### Developer 135 | 136 | - `diff` highlights diff output (requires `colordiff` or `Git`). 137 | - `make` highlights make output (requires `colormake`). 138 | - `wdiff` highlights wdiff output (requires `wdiff `or `Git`). 139 | 140 | ### Resource usage 141 | 142 | - `psu` displays user owned processes status. 143 | 144 | ### Search and Replace 145 | 146 | - `prep` provides a grep-like pattern search. 147 | - `psub` provides a sed-like pattern substitution. 148 | 149 | Authors 150 | ------- 151 | 152 | *The authors of this module should be contacted via the [issue tracker][1].* 153 | 154 | - [Robby Russell](https://github.com/robbyrussell) 155 | - [Suraj N. Kurapati](https://github.com/sunaku) 156 | - [Sorin Ionescu](https://github.com/sorin-ionescu) 157 | 158 | [1]: https://github.com/sorin-ionescu/prezto/issues 159 | 160 | -------------------------------------------------------------------------------- /modules/utility/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines general aliases and functions. 3 | # 4 | # Authors: 5 | # Robby Russell 6 | # Suraj N. Kurapati 7 | # Sorin Ionescu 8 | # 9 | 10 | # Load dependencies. 11 | pmodload 'helper' 'spectrum' 12 | 13 | # Correct commands. 14 | setopt CORRECT 15 | 16 | # 17 | # Aliases 18 | # 19 | 20 | # Disable correction. 21 | alias ack='nocorrect ack' 22 | alias cd='nocorrect cd' 23 | alias cp='nocorrect cp' 24 | alias ebuild='nocorrect ebuild' 25 | alias gcc='nocorrect gcc' 26 | alias gist='nocorrect gist' 27 | alias grep='nocorrect grep' 28 | alias heroku='nocorrect heroku' 29 | alias ln='nocorrect ln' 30 | alias man='nocorrect man' 31 | alias mkdir='nocorrect mkdir' 32 | alias mv='nocorrect mv' 33 | alias mysql='nocorrect mysql' 34 | alias rm='nocorrect rm' 35 | 36 | # Disable globbing. 37 | alias bower='noglob bower' 38 | alias fc='noglob fc' 39 | alias find='noglob find' 40 | alias ftp='noglob ftp' 41 | alias history='noglob history' 42 | alias locate='noglob locate' 43 | alias rake='noglob rake' 44 | alias rsync='noglob rsync' 45 | alias scp='noglob scp' 46 | alias sftp='noglob sftp' 47 | 48 | # Define general aliases. 49 | alias _='sudo' 50 | alias b='${(z)BROWSER}' 51 | alias cp="${aliases[cp]:-cp} -i" 52 | alias e='${(z)VISUAL:-${(z)EDITOR}}' 53 | alias ln="${aliases[ln]:-ln} -i" 54 | alias mkdir="${aliases[mkdir]:-mkdir} -p" 55 | alias mv="${aliases[mv]:-mv} -i" 56 | alias p='${(z)PAGER}' 57 | alias po='popd' 58 | alias pu='pushd' 59 | alias rm="${aliases[rm]:-rm} -i" 60 | alias type='type -a' 61 | 62 | # ls 63 | if is-callable 'dircolors'; then 64 | # GNU Core Utilities 65 | alias ls='ls --group-directories-first' 66 | 67 | if zstyle -t ':prezto:module:utility:ls' color; then 68 | if [[ -s "$HOME/.dir_colors" ]]; then 69 | eval "$(dircolors "$HOME/.dir_colors")" 70 | else 71 | eval "$(dircolors)" 72 | fi 73 | 74 | alias ls="$aliases[ls] --color=auto" 75 | else 76 | alias ls="$aliases[ls] -F" 77 | fi 78 | else 79 | # BSD Core Utilities 80 | if zstyle -t ':prezto:module:utility:ls' color; then 81 | # Define colors for BSD ls. 82 | export LSCOLORS='exfxcxdxbxGxDxabagacad' 83 | 84 | # Define colors for the completion system. 85 | export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' 86 | 87 | alias ls='ls -G' 88 | else 89 | alias ls='ls -F' 90 | fi 91 | fi 92 | 93 | alias l='ls -1A' # Lists in one column, hidden files. 94 | alias ll='ls -lh' # Lists human readable sizes. 95 | alias lr='ll -R' # Lists human readable sizes, recursively. 96 | alias la='ll -A' # Lists human readable sizes, hidden files. 97 | alias lm='la | "$PAGER"' # Lists human readable sizes, hidden files through pager. 98 | alias lx='ll -XB' # Lists sorted by extension (GNU only). 99 | alias lk='ll -Sr' # Lists sorted by size, largest last. 100 | alias lt='ll -tr' # Lists sorted by date, most recent last. 101 | alias lc='lt -c' # Lists sorted by date, most recent last, shows change time. 102 | alias lu='lt -u' # Lists sorted by date, most recent last, shows access time. 103 | alias sl='ls' # I often screw this up. 104 | 105 | # Mac OS X Everywhere 106 | if [[ "$OSTYPE" == darwin* ]]; then 107 | alias o='open' 108 | elif [[ "$OSTYPE" == cygwin* ]]; then 109 | alias o='cygstart' 110 | alias pbcopy='tee > /dev/clipboard' 111 | alias pbpaste='cat /dev/clipboard' 112 | else 113 | alias o='xdg-open' 114 | 115 | if (( $+commands[xclip] )); then 116 | alias pbcopy='xclip -selection clipboard -in' 117 | alias pbpaste='xclip -selection clipboard -out' 118 | elif (( $+commands[xsel] )); then 119 | alias pbcopy='xsel --clipboard --input' 120 | alias pbpaste='xsel --clipboard --output' 121 | fi 122 | fi 123 | 124 | alias pbc='pbcopy' 125 | alias pbp='pbpaste' 126 | 127 | # File Download 128 | if (( $+commands[curl] )); then 129 | alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time' 130 | elif (( $+commands[wget] )); then 131 | alias get='wget --continue --progress=bar --timestamping' 132 | fi 133 | 134 | # Resource Usage 135 | alias df='df -kh' 136 | alias du='du -kh' 137 | 138 | if (( $+commands[htop] )); then 139 | alias top=htop 140 | else 141 | alias topc='top -o cpu' 142 | alias topm='top -o vsize' 143 | fi 144 | 145 | # Miscellaneous 146 | 147 | # Serves a directory via HTTP. 148 | alias http-serve='python -m SimpleHTTPServer' 149 | 150 | # 151 | # Functions 152 | # 153 | 154 | # Makes a directory and changes to it. 155 | function mkdcd { 156 | [[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1" 157 | } 158 | 159 | # Changes to a directory and lists its contents. 160 | function cdls { 161 | builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}" 162 | } 163 | 164 | # Pushes an entry onto the directory stack and lists its contents. 165 | function pushdls { 166 | builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}" 167 | } 168 | 169 | # Pops an entry off the directory stack and lists its contents. 170 | function popdls { 171 | builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}" 172 | } 173 | 174 | # Prints columns 1 2 3 ... n. 175 | function slit { 176 | awk "{ print ${(j:,:):-\$${^@}} }" 177 | } 178 | 179 | # Finds files and executes a command on them. 180 | function find-exec { 181 | find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; 182 | } 183 | 184 | # Displays user owned processes status. 185 | function psu { 186 | ps -U "${1:-$USER}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}" 187 | } 188 | 189 | -------------------------------------------------------------------------------- /modules/git/alias.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Defines Git aliases. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # Settings 10 | # 11 | # 12 | 13 | # Log 14 | zstyle -s ':prezto:module:git:log:medium' format '_git_log_medium_format' \ 15 | || _git_log_medium_format='%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B' 16 | zstyle -s ':prezto:module:git:log:oneline' format '_git_log_oneline_format' \ 17 | || _git_log_oneline_format='%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n' 18 | zstyle -s ':prezto:module:git:log:brief' format '_git_log_brief_format' \ 19 | || _git_log_brief_format='%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n' 20 | 21 | # Status 22 | zstyle -s ':prezto:module:git:status:ignore' submodules '_git_status_ignore_submodules' \ 23 | || _git_status_ignore_submodules='none' 24 | 25 | # 26 | # Aliases 27 | # 28 | 29 | # Git 30 | alias g='git' 31 | 32 | # Branch (b) 33 | alias gb='git branch' 34 | alias gbc='git checkout -b' 35 | alias gbl='git branch -v' 36 | alias gbL='git branch -av' 37 | alias gbx='git branch -d' 38 | alias gbX='git branch -D' 39 | alias gbm='git branch -m' 40 | alias gbM='git branch -M' 41 | alias gbs='git show-branch' 42 | alias gbS='git show-branch -a' 43 | 44 | # Commit (c) 45 | alias gc='git commit --verbose' 46 | alias gca='git commit --verbose --all' 47 | alias gcm='git commit --message' 48 | alias gco='git checkout' 49 | alias gcO='git checkout --patch' 50 | alias gcf='git commit --amend --reuse-message HEAD' 51 | alias gcF='git commit --verbose --amend' 52 | alias gcp='git cherry-pick --ff' 53 | alias gcP='git cherry-pick --no-commit' 54 | alias gcr='git revert' 55 | alias gcR='git reset "HEAD^"' 56 | alias gcs='git show' 57 | alias gcl='git-commit-lost' 58 | 59 | # Conflict (C) 60 | alias gCl='git status | sed -n "s/^.*both [a-z]*ed: *//p"' 61 | alias gCa='git add $(gCl)' 62 | alias gCe='git mergetool $(gCl)' 63 | alias gCo='git checkout --ours --' 64 | alias gCO='gCo $(gCl)' 65 | alias gCt='git checkout --theirs --' 66 | alias gCT='gCt $(gCl)' 67 | 68 | # Data (d) 69 | alias gd='git ls-files' 70 | alias gdc='git ls-files --cached' 71 | alias gdx='git ls-files --deleted' 72 | alias gdm='git ls-files --modified' 73 | alias gdu='git ls-files --other --exclude-standard' 74 | alias gdk='git ls-files --killed' 75 | alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"' 76 | 77 | # Fetch (f) 78 | alias gf='git fetch' 79 | alias gfc='git clone' 80 | alias gfm='git pull' 81 | alias gfr='git pull --rebase' 82 | 83 | # Grep (g) 84 | alias gg='git grep' 85 | alias ggi='git grep --ignore-case' 86 | alias ggl='git grep --files-with-matches' 87 | alias ggL='git grep --files-without-matches' 88 | alias ggv='git grep --invert-match' 89 | alias ggw='git grep --word-regexp' 90 | 91 | # Index (i) 92 | alias gia='git add' 93 | alias giA='git add --patch' 94 | alias giu='git add --update' 95 | alias gid='git diff --no-ext-diff --cached' 96 | alias giD='git diff --no-ext-diff --cached --word-diff' 97 | alias gir='git reset' 98 | alias giR='git reset --patch' 99 | alias gix='git rm -r --cached' 100 | alias giX='git rm -rf --cached' 101 | 102 | # Log (l) 103 | alias gl='git log --topo-order --pretty=format:${_git_log_medium_format}' 104 | alias gls='git log --topo-order --stat --pretty=format:${_git_log_medium_format}' 105 | alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:${_git_log_medium_format}' 106 | alias glo='git log --topo-order --pretty=format:${_git_log_oneline_format}' 107 | alias glg='git log --topo-order --all --graph --pretty=format:${_git_log_oneline_format}' 108 | alias glb='git log --topo-order --pretty=format:${_git_log_brief_format}' 109 | alias glc='git shortlog --summary --numbered' 110 | 111 | # Merge (m) 112 | alias gm='git merge' 113 | alias gmC='git merge --no-commit' 114 | alias gmF='git merge --no-ff' 115 | alias gma='git merge --abort' 116 | alias gmt='git mergetool' 117 | 118 | # Push (p) 119 | alias gp='git push' 120 | alias gpf='git push --force' 121 | alias gpa='git push --all' 122 | alias gpA='git push --all && git push --tags' 123 | alias gpt='git push --tags' 124 | alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"' 125 | alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"' 126 | 127 | # Rebase (r) 128 | alias gr='git rebase' 129 | alias gra='git rebase --abort' 130 | alias grc='git rebase --continue' 131 | alias gri='git rebase --interactive' 132 | alias grs='git rebase --skip' 133 | 134 | # Remote (R) 135 | alias gR='git remote' 136 | alias gRl='git remote --verbose' 137 | alias gRa='git remote add' 138 | alias gRx='git remote rm' 139 | alias gRm='git remote rename' 140 | alias gRu='git remote update' 141 | alias gRp='git remote prune' 142 | alias gRs='git remote show' 143 | alias gRb='git-hub-browse' 144 | 145 | # Stash (s) 146 | alias gs='git stash' 147 | alias gsa='git stash apply' 148 | alias gsx='git stash drop' 149 | alias gsX='git-stash-clear-interactive' 150 | alias gsl='git stash list' 151 | alias gsL='git-stash-dropped' 152 | alias gsd='git stash show --patch --stat' 153 | alias gsp='git stash pop' 154 | alias gsr='git-stash-recover' 155 | alias gss='git stash save --include-untracked' 156 | alias gsS='git stash save --patch --no-keep-index' 157 | alias gsw='git stash save --include-untracked --keep-index' 158 | 159 | # Submodule (S) 160 | alias gS='git submodule' 161 | alias gSa='git submodule add' 162 | alias gSf='git submodule foreach' 163 | alias gSi='git submodule init' 164 | alias gSI='git submodule update --init --recursive' 165 | alias gSl='git submodule status' 166 | alias gSm='git-submodule-move' 167 | alias gSs='git submodule sync' 168 | alias gSu='git submodule foreach git pull origin master' 169 | alias gSx='git-submodule-remove' 170 | 171 | # Working Copy (w) 172 | alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short' 173 | alias gwS='git status --ignore-submodules=${_git_status_ignore_submodules}' 174 | alias gwd='git diff --no-ext-diff' 175 | alias gwD='git diff --no-ext-diff --word-diff' 176 | alias gwr='git reset --soft' 177 | alias gwR='git reset --hard' 178 | alias gwc='git clean -n' 179 | alias gwC='git clean -f' 180 | alias gwx='git rm -r' 181 | alias gwX='git rm -rf' 182 | 183 | -------------------------------------------------------------------------------- /modules/completion/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets completion options. 3 | # 4 | # Authors: 5 | # Robby Russell 6 | # Sorin Ionescu 7 | # 8 | 9 | # Return if requirements are not found. 10 | if [[ "$TERM" == 'dumb' ]]; then 11 | return 1 12 | fi 13 | 14 | # Add zsh-completions to $fpath. 15 | fpath=("${0:h}/external/src" $fpath) 16 | 17 | # Load and initialize the completion system ignoring insecure directories. 18 | autoload -Uz compinit && compinit -i 19 | 20 | # 21 | # Options 22 | # 23 | 24 | setopt COMPLETE_IN_WORD # Complete from both ends of a word. 25 | setopt ALWAYS_TO_END # Move cursor to the end of a completed word. 26 | setopt PATH_DIRS # Perform path search even on command names with slashes. 27 | setopt AUTO_MENU # Show completion menu on a succesive tab press. 28 | setopt AUTO_LIST # Automatically list choices on ambiguous completion. 29 | setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash. 30 | unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. 31 | unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. 32 | 33 | # 34 | # Styles 35 | # 36 | 37 | # Use caching to make completion for cammands such as dpkg and apt usable. 38 | zstyle ':completion::complete:*' use-cache on 39 | zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.zcompcache" 40 | 41 | # Case-insensitive (all), partial-word, and then substring completion. 42 | if zstyle -t ':prezto:module:completion:*' case-sensitive; then 43 | zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 44 | setopt CASE_GLOB 45 | else 46 | zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 47 | unsetopt CASE_GLOB 48 | fi 49 | 50 | # Group matches and describe. 51 | zstyle ':completion:*:*:*:*:*' menu select 52 | zstyle ':completion:*:matches' group 'yes' 53 | zstyle ':completion:*:options' description 'yes' 54 | zstyle ':completion:*:options' auto-description '%d' 55 | zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f' 56 | zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f' 57 | zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' 58 | zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' 59 | zstyle ':completion:*:default' list-prompt '%S%M matches%s' 60 | zstyle ':completion:*' format ' %F{yellow}-- %d --%f' 61 | zstyle ':completion:*' group-name '' 62 | zstyle ':completion:*' verbose yes 63 | 64 | # Fuzzy match mistyped completions. 65 | zstyle ':completion:*' completer _complete _match _approximate 66 | zstyle ':completion:*:match:*' original only 67 | zstyle ':completion:*:approximate:*' max-errors 1 numeric 68 | 69 | # Increase the number of errors based on the length of the typed word. 70 | zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' 71 | 72 | # Don't complete unavailable commands. 73 | zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))' 74 | 75 | # Array completion element sorting. 76 | zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters 77 | 78 | # Directories 79 | zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 80 | zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories 81 | zstyle ':completion:*:*:cd:*:directory-stack' menu yes select 82 | zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand' 83 | zstyle ':completion:*' squeeze-slashes true 84 | 85 | # History 86 | zstyle ':completion:*:history-words' stop yes 87 | zstyle ':completion:*:history-words' remove-all-dups yes 88 | zstyle ':completion:*:history-words' list false 89 | zstyle ':completion:*:history-words' menu yes 90 | 91 | # Environmental Variables 92 | zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-} 93 | 94 | # Populate hostname completion. 95 | zstyle -e ':completion:*:hosts' hosts 'reply=( 96 | ${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } 97 | ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} 98 | ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} 99 | )' 100 | 101 | # Don't complete uninteresting users... 102 | zstyle ':completion:*:*:*:users' ignored-patterns \ 103 | adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ 104 | dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ 105 | hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ 106 | mailman mailnull mldonkey mysql nagios \ 107 | named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ 108 | operator pcap postfix postgres privoxy pulse pvm quagga radvd \ 109 | rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*' 110 | 111 | # ... unless we really want to. 112 | zstyle '*' single-ignored show 113 | 114 | # Ignore multiple entries. 115 | zstyle ':completion:*:(rm|kill|diff):*' ignore-line other 116 | zstyle ':completion:*:rm:*' file-patterns '*:all-files' 117 | 118 | # Kill 119 | zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm -w' 120 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01' 121 | zstyle ':completion:*:*:kill:*' menu yes select 122 | zstyle ':completion:*:*:kill:*' force-list always 123 | zstyle ':completion:*:*:kill:*' insert-ids single 124 | 125 | # Man 126 | zstyle ':completion:*:manuals' separate-sections true 127 | zstyle ':completion:*:manuals.(^1*)' insert-sections true 128 | 129 | # Media Players 130 | zstyle ':completion:*:*:mpg123:*' file-patterns '*.(mp3|MP3):mp3\ files *(-/):directories' 131 | zstyle ':completion:*:*:mpg321:*' file-patterns '*.(mp3|MP3):mp3\ files *(-/):directories' 132 | zstyle ':completion:*:*:ogg123:*' file-patterns '*.(ogg|OGG|flac):ogg\ files *(-/):directories' 133 | zstyle ':completion:*:*:mocp:*' file-patterns '*.(wav|WAV|mp3|MP3|ogg|OGG|flac):ogg\ files *(-/):directories' 134 | 135 | # Mutt 136 | if [[ -s "$HOME/.mutt/aliases" ]]; then 137 | zstyle ':completion:*:*:mutt:*' menu yes select 138 | zstyle ':completion:*:mutt:*' users ${${${(f)"$(<"$HOME/.mutt/aliases")"}#alias[[:space:]]}%%[[:space:]]*} 139 | fi 140 | 141 | # SSH/SCP/RSYNC 142 | zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' 143 | zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr 144 | zstyle ':completion:*:ssh:*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' 145 | zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr 146 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost 147 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' 148 | zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' 149 | 150 | -------------------------------------------------------------------------------- /modules/editor/init.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # Sets key bindings. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # Return if requirements are not found. 9 | if [[ "$TERM" == 'dumb' ]]; then 10 | return 1 11 | fi 12 | 13 | # 14 | # Options 15 | # 16 | 17 | # Beep on error in line editor. 18 | setopt BEEP 19 | 20 | # 21 | # Variables 22 | # 23 | 24 | # Treat these characters as part of a word. 25 | WORDCHARS='*?_-.[]~&;!#$%^(){}<>' 26 | 27 | # Use human-friendly identifiers. 28 | zmodload zsh/terminfo 29 | typeset -gA key_info 30 | key_info=( 31 | 'Control' '\C-' 32 | 'Escape' '\e' 33 | 'Meta' '\M-' 34 | 'Backspace' "^?" 35 | 'Delete' "^[[3~" 36 | 'F1' "$terminfo[kf1]" 37 | 'F2' "$terminfo[kf2]" 38 | 'F3' "$terminfo[kf3]" 39 | 'F4' "$terminfo[kf4]" 40 | 'F5' "$terminfo[kf5]" 41 | 'F6' "$terminfo[kf6]" 42 | 'F7' "$terminfo[kf7]" 43 | 'F8' "$terminfo[kf8]" 44 | 'F9' "$terminfo[kf9]" 45 | 'F10' "$terminfo[kf10]" 46 | 'F11' "$terminfo[kf11]" 47 | 'F12' "$terminfo[kf12]" 48 | 'Insert' "$terminfo[kich1]" 49 | 'Home' "$terminfo[khome]" 50 | 'PageUp' "$terminfo[kpp]" 51 | 'End' "$terminfo[kend]" 52 | 'PageDown' "$terminfo[knp]" 53 | 'Up' "$terminfo[kcuu1]" 54 | 'Left' "$terminfo[kcub1]" 55 | 'Down' "$terminfo[kcud1]" 56 | 'Right' "$terminfo[kcuf1]" 57 | 'BackTab' "$terminfo[kcbt]" 58 | ) 59 | 60 | # Set empty $key_info values to an invalid UTF-8 sequence to induce silent 61 | # bindkey failure. 62 | for key in "${(k)key_info[@]}"; do 63 | if [[ -z "$key_info[$key]" ]]; then 64 | key_info["$key"]='�' 65 | fi 66 | done 67 | 68 | # 69 | # External Editor 70 | # 71 | 72 | # Allow command line editing in an external editor. 73 | autoload -Uz edit-command-line 74 | zle -N edit-command-line 75 | 76 | # 77 | # Functions 78 | # 79 | 80 | # Exposes information about the Zsh Line Editor via the $editor_info associative 81 | # array. 82 | function editor-info { 83 | # Clean up previous $editor_info. 84 | unset editor_info 85 | typeset -gA editor_info 86 | 87 | if [[ "$KEYMAP" == 'vicmd' ]]; then 88 | zstyle -s ':prezto:module:editor:info:keymap:alternate' format 'REPLY' 89 | editor_info[keymap]="$REPLY" 90 | else 91 | zstyle -s ':prezto:module:editor:info:keymap:primary' format 'REPLY' 92 | editor_info[keymap]="$REPLY" 93 | 94 | if [[ "$ZLE_STATE" == *overwrite* ]]; then 95 | zstyle -s ':prezto:module:editor:info:keymap:primary:overwrite' format 'REPLY' 96 | editor_info[overwrite]="$REPLY" 97 | else 98 | zstyle -s ':prezto:module:editor:info:keymap:primary:insert' format 'REPLY' 99 | editor_info[overwrite]="$REPLY" 100 | fi 101 | fi 102 | 103 | unset REPLY 104 | 105 | zle reset-prompt 106 | zle -R 107 | } 108 | zle -N editor-info 109 | 110 | # Updates editor information when the keymap changes. 111 | function zle-keymap-select { 112 | zle editor-info 113 | } 114 | zle -N zle-keymap-select 115 | 116 | # Enables terminal application mode and updates editor information. 117 | function zle-line-init { 118 | # The terminal must be in application mode when ZLE is active for $terminfo 119 | # values to be valid. 120 | if (( $+terminfo[smkx] )); then 121 | # Enable terminal application mode. 122 | echoti smkx 123 | fi 124 | 125 | # Update editor information. 126 | zle editor-info 127 | } 128 | zle -N zle-line-init 129 | 130 | # Disables terminal application mode and updates editor information. 131 | function zle-line-finish { 132 | # The terminal must be in application mode when ZLE is active for $terminfo 133 | # values to be valid. 134 | if (( $+terminfo[rmkx] )); then 135 | # Disable terminal application mode. 136 | echoti rmkx 137 | fi 138 | 139 | # Update editor information. 140 | zle editor-info 141 | } 142 | zle -N zle-line-finish 143 | 144 | # Toggles emacs overwrite mode and updates editor information. 145 | function overwrite-mode { 146 | zle .overwrite-mode 147 | zle editor-info 148 | } 149 | zle -N overwrite-mode 150 | 151 | # Enters vi insert mode and updates editor information. 152 | function vi-insert { 153 | zle .vi-insert 154 | zle editor-info 155 | } 156 | zle -N vi-insert 157 | 158 | # Moves to the first non-blank character then enters vi insert mode and updates 159 | # editor information. 160 | function vi-insert-bol { 161 | zle .vi-insert-bol 162 | zle editor-info 163 | } 164 | zle -N vi-insert-bol 165 | 166 | # Enters vi replace mode and updates editor information. 167 | function vi-replace { 168 | zle .vi-replace 169 | zle editor-info 170 | } 171 | zle -N vi-replace 172 | 173 | # Expands .... to ../.. 174 | function expand-dot-to-parent-directory-path { 175 | if [[ $LBUFFER = *.. ]]; then 176 | LBUFFER+='/..' 177 | else 178 | LBUFFER+='.' 179 | fi 180 | } 181 | zle -N expand-dot-to-parent-directory-path 182 | 183 | # Displays an indicator when completing. 184 | function expand-or-complete-with-indicator { 185 | local indicator 186 | zstyle -s ':prezto:module:editor:info:completing' format 'indicator' 187 | print -Pn "$indicator" 188 | zle expand-or-complete 189 | zle redisplay 190 | } 191 | zle -N expand-or-complete-with-indicator 192 | 193 | # Inserts 'sudo ' at the beginning of the line. 194 | function prepend-sudo { 195 | if [[ "$BUFFER" != su(do|)\ * ]]; then 196 | BUFFER="sudo $BUFFER" 197 | (( CURSOR += 5 )) 198 | fi 199 | } 200 | zle -N prepend-sudo 201 | 202 | # Reset to default key bindings. 203 | bindkey -d 204 | 205 | # 206 | # Emacs Key Bindings 207 | # 208 | 209 | for key ("$key_info[Escape]"{B,b}) bindkey -M emacs "$key" emacs-backward-word 210 | for key ("$key_info[Escape]"{F,f}) bindkey -M emacs "$key" emacs-forward-word 211 | bindkey -M emacs "$key_info[Escape]$key_info[Left]" emacs-backward-word 212 | bindkey -M emacs "$key_info[Escape]$key_info[Right]" emacs-forward-word 213 | 214 | # Kill to the beginning of the line. 215 | for key in "$key_info[Escape]"{K,k} 216 | bindkey -M emacs "$key" backward-kill-line 217 | 218 | # Redo. 219 | bindkey -M emacs "$key_info[Escape]_" redo 220 | 221 | # Search previous character. 222 | bindkey -M emacs "$key_info[Control]X$key_info[Control]B" vi-find-prev-char 223 | 224 | # Match bracket. 225 | bindkey -M emacs "$key_info[Control]X$key_info[Control]]" vi-match-bracket 226 | 227 | # Edit command in an external editor. 228 | bindkey -M emacs "$key_info[Control]X$key_info[Control]E" edit-command-line 229 | 230 | if (( $+widgets[history-incremental-pattern-search-backward] )); then 231 | bindkey -M emacs "$key_info[Control]R" \ 232 | history-incremental-pattern-search-backward 233 | bindkey -M emacs "$key_info[Control]S" \ 234 | history-incremental-pattern-search-forward 235 | fi 236 | 237 | # 238 | # Vi Key Bindings 239 | # 240 | 241 | # Edit command in an external editor. 242 | bindkey -M vicmd "v" edit-command-line 243 | 244 | # Undo/Redo 245 | bindkey -M vicmd "u" undo 246 | bindkey -M vicmd "$key_info[Control]R" redo 247 | 248 | if (( $+widgets[history-incremental-pattern-search-backward] )); then 249 | bindkey -M vicmd "?" history-incremental-pattern-search-backward 250 | bindkey -M vicmd "/" history-incremental-pattern-search-forward 251 | else 252 | bindkey -M vicmd "?" history-incremental-search-backward 253 | bindkey -M vicmd "/" history-incremental-search-forward 254 | fi 255 | 256 | # 257 | # Emacs and Vi Key Bindings 258 | # 259 | 260 | for keymap in 'emacs' 'viins'; do 261 | bindkey -M "$keymap" "$key_info[Home]" beginning-of-line 262 | bindkey -M "$keymap" "$key_info[End]" end-of-line 263 | 264 | bindkey -M "$keymap" "$key_info[Insert]" overwrite-mode 265 | bindkey -M "$keymap" "$key_info[Delete]" delete-char 266 | bindkey -M "$keymap" "$key_info[Backspace]" backward-delete-char 267 | 268 | bindkey -M "$keymap" "$key_info[Left]" backward-char 269 | bindkey -M "$keymap" "$key_info[Right]" forward-char 270 | 271 | # Expand history on space. 272 | bindkey -M "$keymap" ' ' magic-space 273 | 274 | # Clear screen. 275 | bindkey -M "$keymap" "$key_info[Control]L" clear-screen 276 | 277 | # Expand command name to full path. 278 | for key in "$key_info[Escape]"{E,e} 279 | bindkey -M "$keymap" "$key" expand-cmd-path 280 | 281 | # Duplicate the previous word. 282 | for key in "$key_info[Escape]"{M,m} 283 | bindkey -M "$keymap" "$key" copy-prev-shell-word 284 | 285 | # Use a more flexible push-line. 286 | for key in "$key_info[Control]Q" "$key_info[Escape]"{q,Q} 287 | bindkey -M "$keymap" "$key" push-line-or-edit 288 | 289 | # Bind Shift + Tab to go to the previous menu item. 290 | bindkey -M "$keymap" "$key_info[BackTab]" reverse-menu-complete 291 | 292 | # Complete in the middle of word. 293 | bindkey -M "$keymap" "$key_info[Control]I" expand-or-complete 294 | 295 | # Expand .... to ../.. 296 | if zstyle -t ':prezto:module:editor' dot-expansion; then 297 | bindkey -M "$keymap" "." expand-dot-to-parent-directory-path 298 | fi 299 | 300 | # Display an indicator when completing. 301 | bindkey -M "$keymap" "$key_info[Control]I" \ 302 | expand-or-complete-with-indicator 303 | 304 | # Insert 'sudo ' at the beginning of the line. 305 | bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo 306 | done 307 | 308 | # Do not expand .... to ../.. during incremental search. 309 | if zstyle -t ':prezto:module:editor' dot-expansion; then 310 | bindkey -M isearch . self-insert 2> /dev/null 311 | fi 312 | 313 | # 314 | # Layout 315 | # 316 | 317 | # Set the key layout. 318 | zstyle -s ':prezto:module:editor' key-bindings 'key_bindings' 319 | if [[ "$key_bindings" == (emacs|) ]]; then 320 | bindkey -e 321 | elif [[ "$key_bindings" == vi ]]; then 322 | bindkey -v 323 | else 324 | print "prezto: editor: invalid key bindings: $key_bindings" >&2 325 | fi 326 | 327 | unset key{,map,bindings} 328 | 329 | --------------------------------------------------------------------------------