diff --git a/README.md b/README.md index 4c5ba303..7892f8ca 100644 --- a/README.md +++ b/README.md @@ -11,23 +11,26 @@ Installation Oh My Zsh will work with any recent release of Zsh, but the minimum recommended version is 4.3.10. - 1. Clone the repository: + 1. Clone the repository: - `git clone https://github.com/sorin-ionescu/oh-my-zsh.git ~/.oh-my-zsh` + git clone https://github.com/sorin-ionescu/oh-my-zsh.git ~/.oh-my-zsh - 2. Initialize the submodules: + 2. Initialize the submodules: - `cd ~/.oh-my-zsh && git submodule update --init --recursive` + cd ~/.oh-my-zsh && git submodule update --init --recursive - 3. Create a new Zsh configuration by copying the Zsh template provided: + 3. Create a new Zsh configuration by copying the Zsh configuration file + templates provided: - `cp ~/.oh-my-zsh/templates/zshrc ~/.zshrc` + for rcfile in ~/.oh-my-zsh/templates/z{shenv,shrc,login,logout}; do + cp -f "${rcfile}" "${HOME}/.${rcfile}" + done - 4. Set Zsh as your default shell: + 4. Set Zsh as your default shell: - `chsh -s /bin/zsh` + chsh -s /bin/zsh - 5. Open a new Zsh terminal window or tab. + 5. Open a new Zsh terminal window or tab. ### Mac OS X @@ -51,29 +54,32 @@ directories end up at the tail of the array. ### Troubleshooting If you are not able to find certain commands after switching to *Oh My Zsh*, -modify the `PATH` variable in *environment.zsh* then open a new Zsh terminal +modify the `PATH` variable in *~/.zshenv* then open a new Zsh terminal window or tab. -## Usage +Usage +----- Oh My Zsh has many features disabled by default. Read the source code and accompanying README files to learn of what is available. ### Modules - 1. Browse */modules* to see what is available. - 2. Load the modules you need in *~/.zshrc* then open a new Zsh terminal - window or tab. + 1. Browse */modules* to see what is available. + 2. Load the modules you need in *~/.zshrc* then open a new Zsh terminal window + or tab. ### Themes - 1. For a list of themes, type `prompt -l`. - 2. To preview a theme, type `prompt -p name`. - 3. Load the theme you like in *~/.zshrc* then open a new Zsh terminal window - or tab. - ![sorin theme][2] + 1. For a list of themes, type `prompt -l`. + 2. To preview a theme, type `prompt -p name`. + 3. Load the theme you like in *~/.zshrc* then open a new Zsh terminal window + or tab. -## Customization + ![sorin theme][2] + +Customization +------------- The project is managed via [Git][3]. It is highly recommend that you commit your changes and push them to [GitHub][4] to not lose them. If you do not know @@ -84,18 +90,21 @@ how to use Git, follow this [tutorial][5] and bookmark this [reference][6]. Submit program completions to the [zsh-completions][7] project. The Oh My Zsh completions directory will be synched against it. -## Resources +Resources +--------- The [Zsh Reference Card][8] is indispensable. -## Contribute +Contribute +---------- This project would not exist without all of its users and [contributors][9]. If you have ideas on how to make the configuration easier to maintain or improve its performance, do not hesitate to fork and send pull requests. -## License +License +------- (The MIT License) diff --git a/init.zsh b/init.zsh index a8157241..9b466450 100644 --- a/init.zsh +++ b/init.zsh @@ -38,18 +38,3 @@ zstyle -a ':omz:load' omodule 'omodules' omodload "$omodules[@]" unset omodules -# Set environment variables for launchd processes. -if [[ "$OSTYPE" == darwin* ]]; then - for env_var in PATH MANPATH; do - launchctl setenv "$env_var" "${(P)env_var}" &! - done - unset env_var -fi - -# Compile the completion dump, to increase startup speed. -dump_file="$HOME/.zcompdump" -if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -s "${dump_file}.zwc" ]]; then - zcompile "$dump_file" -fi -unset dump_file - diff --git a/modules/archive/README.md b/modules/archive/README.md new file mode 100644 index 00000000..c997ddb2 --- /dev/null +++ b/modules/archive/README.md @@ -0,0 +1,41 @@ +Archive +======= + +Provides functions to extract and list popular archive formats. + +Functions +--------- + + - `extract` extracts the contents of one or more archives. + - `ls-archive` lists the contents of one or more archives. + +Supported Formats +----------------- + +The following archive formats are supported when the required utilities are +installed: + + - *.tar.gz*, *.tgz* require `tar`. + - *.tar.bz2*, *.tbz* require `tar`. + - *.tar.xz*, *.txz* require `tar` with *xz* support. + - *.tar.zma*, *.tlz* require `tar` with *lzma* support. + - *.tar* requires `tar`. + - *.gz* requires `gunzip`. + - *.bz2* requires `bunzip2`. + - *.xz* requires `unxz`. + - *.lzma* requires `unlzma`. + - *.Z* requires `uncompress`. + - *.zip* requires `unzip`. + - *.rar* requires `unrar`. + - *.7z* requires `7za`. + - *.deb* requires `ar`, `tar`. + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][1].* + + - [Sorin Ionescu](https://github.com/sorin-ionescu) + +[1]: https://github.com/sorin-ionescu/oh-my-zsh/issues + diff --git a/modules/completion/README.md b/modules/completion/README.md index e265a497..543ae182 100644 --- a/modules/completion/README.md +++ b/modules/completion/README.md @@ -4,15 +4,15 @@ Completion Loads and configures tab completion and provides additional completions from the [zsh-completions][1] project. +This module must be loaded **after** the *alias* module but **before** the +*utility* module. + Contributors ------------ Completions should be submitted to the [zsh-completions][1] project according to its rules and regulations. This module will be synched against it. -This module must be loaded **after** the *alias* module but **before** the -*utility* module. - Authors ------- diff --git a/modules/environment/README.md b/modules/environment/README.md new file mode 100644 index 00000000..01a2ec1b --- /dev/null +++ b/modules/environment/README.md @@ -0,0 +1,26 @@ +Environment +=========== + +Sets general shell options and defines environment variables. + +This module must be loaded first. + +Environment Variables +--------------------- + +Contributors +------------ + +This module **MUST NOT** rely on any command not built in Zsh. + +Non-interactive environment variables should be defined in *zshenv*. + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][1].* + + - [Sorin Ionescu](https://github.com/sorin-ionescu) + +[1]: https://github.com/sorin-ionescu/oh-my-zsh/issues + diff --git a/modules/environment/init.zsh b/modules/environment/init.zsh index 7460e727..cd6f4f76 100644 --- a/modules/environment/init.zsh +++ b/modules/environment/init.zsh @@ -22,86 +22,20 @@ unsetopt BG_NICE # Don't run all background jobs at a lower priority. unsetopt HUP # Don't kill jobs on shell exit. unsetopt CHECK_JOBS # Don't report on jobs when shell exit. -# Paths -typeset -gU cdpath fpath mailpath manpath path -typeset -gUT INFOPATH infopath - -cdpath=( - $HOME - $cdpath -) - -infopath=( - /usr/local/share/info - /usr/share/info - $infopath -) - -manpath=( - /usr/local/share/man - /usr/share/man - $manpath -) - -for path_file in /etc/manpaths.d/*(.N); do - manpath+=($(<$path_file)) -done -unset path_file - -path=( - /usr/local/{bin,sbin} - /usr/{bin,sbin} - /{bin,sbin} - $path -) - -for path_file in /etc/paths.d/*(.N); do - path+=($(<$path_file)) -done -unset path_file - -# Language -if [[ -z "$LANG" ]]; then - eval "$(locale)" -fi - -# Editors -export EDITOR="vim" -export VISUAL="vim" -export PAGER='less' - # Grep if zstyle -t ':omz:environment:grep' color; then export GREP_COLOR='37;45' export GREP_OPTIONS='--color=auto' fi -# Browser (Default) -if [[ "$OSTYPE" == darwin* ]]; then - export BROWSER='open' -fi - -# Less -export LESSCHARSET="UTF-8" -export LESSHISTFILE='-' -export LESSEDIT='vim ?lm+%lm. %f' - -# Mouse-wheel scrolling has been disabled by -X (disable screen clearing). -# Remove -X and -F (exit if the content fits on one screen) to enable it. -export LESS='-F -g -i -M -R -S -w -X -z-4' - -if (( $+commands[lesspipe.sh] )); then - export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' -fi - # Termcap if zstyle -t ':omz:environment:termcap' color; then - export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking - export LESS_TERMCAP_md=$'\E[01;31m' # begin bold - export LESS_TERMCAP_me=$'\E[0m' # end mode - export LESS_TERMCAP_se=$'\E[0m' # end standout-mode - export LESS_TERMCAP_so=$'\E[00;47;30m' # begin standout-mode - export LESS_TERMCAP_ue=$'\E[0m' # end underline - export LESS_TERMCAP_us=$'\E[01;32m' # begin underline + export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking. + export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold. + export LESS_TERMCAP_me=$'\E[0m' # Ends mode. + export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. + export LESS_TERMCAP_so=$'\E[00;47;30m' # Begins standout-mode. + export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. + export LESS_TERMCAP_us=$'\E[01;32m' # Begins underline. fi diff --git a/modules/prompt/init.zsh b/modules/prompt/init.zsh index 973dd711..a92eb233 100644 --- a/modules/prompt/init.zsh +++ b/modules/prompt/init.zsh @@ -5,7 +5,7 @@ # Sorin Ionescu # -# Load and run the prompt theming system. +# Load and execute the prompt theming system. autoload -Uz promptinit && promptinit # Load the prompt theme. diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 00000000..88f16436 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,75 @@ +Zsh Configuration Files +======================= + +Zsh has several system-wide and user-local configuration files. + +System-wide configuration files are installation-dependent but are installed +in */etc* by default. + +User-local configuration files have the same name as their global counterparts +but are prefixed with a dot (hidden). Zsh looks for these files in the path +stored in the `$ZDOTDIR` environmental variable. However, if said variable is +not defined, Zsh will use the user's home directory. + +File Descriptions +----------------- + +The configuration files are read in the following order: + + 01. /etc/zshenv + 02. ~/.zshenv + 03. /etc/zprofile + 04. ~/.zprofile + 05. /etc/zshrc + 06. ~/.zshrc + 07. /etc/zlogin + 08. ~/.zlogin + 09. ~/.zlogout + 10. /etc/zlogout + +### zshenv + +This file is sourced by all instances of Zsh, and thus, it should be kept as +small as possible. It should only define environment variables. + +### zprofile + +This file is similar to zlogin, but it is sourced before zshrc. It was added +for [KornShell][1] fans. See the description of zlogin bellow for what it may +contain. + +zprofile and zlogin are not meant to be used concurrently but can be done so. + +### zshrc + +This file is sourced by interactive shells. It should define aliases, +functions, shell options, and key bindings. + +This is the main Oh My Zsh configuration file. + +### zlogin + +This file is sourced by login shells after zshrc, and thus, it should contain +commands that need to execute at login. It is usually used for messages such as +[fortune][2], [msgs][3], or for the creation of files. + +This is not the file to define aliases, functions, shell options, and key +bindings. It should not change the shell environment. + +### zlogout + +This file is sourced by login shells during logout. It should be used for +displaying messages and the deletion of files. + +Authors +------- + +*The authors of these files should be contacted via the [issue tracker][4].* + + - [Sorin Ionescu](https://github.com/sorin-ionescu) + +[1]: http://www.kornshell.com +[2]: http://en.wikipedia.org/wiki/Fortune_(Unix) +[3]: http://www.manpagez.com/man/1/msgs +[4]: https://github.com/sorin-ionescu/oh-my-zsh/issues + diff --git a/templates/zlogin b/templates/zlogin new file mode 100644 index 00000000..2854965a --- /dev/null +++ b/templates/zlogin @@ -0,0 +1,29 @@ +# +# Executes commands at login post-zshrc. +# +# Authors: +# Sorin Ionescu +# + +# Execute code that does not affect the current session in the background. +{ + # Compile the completion dump to increase startup speed. + dump_file="$HOME/.zcompdump" + if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -s "${dump_file}.zwc" ]]; then + zcompile "$dump_file" + fi + + # Set environment variables for launchd processes. + if [[ "$OSTYPE" == darwin* ]]; then + for env_var in PATH MANPATH; do + launchctl setenv "$env_var" "${(P)env_var}" + done + fi +} &! + +# Print a random, hopefully interesting, adage. +if (( $+commands[fortune] )); then + fortune -a + print +fi + diff --git a/templates/zlogout b/templates/zlogout new file mode 100644 index 00000000..d898fec1 --- /dev/null +++ b/templates/zlogout @@ -0,0 +1,14 @@ +# +# Executes commands at logout. +# +# Authors: +# Sorin Ionescu +# + +# Print the message. +cat <<-EOF + +Thank you. Come again! + -- Dr. Apu Nahasapeemapetilon +EOF + diff --git a/templates/zprofile b/templates/zprofile new file mode 100644 index 00000000..2a3d07e6 --- /dev/null +++ b/templates/zprofile @@ -0,0 +1,7 @@ +# +# Executes commands at login pre-zshrc. +# +# Authors: +# Sorin Ionescu +# + diff --git a/templates/zshenv b/templates/zshenv new file mode 100644 index 00000000..af83ce06 --- /dev/null +++ b/templates/zshenv @@ -0,0 +1,78 @@ +# +# Defines environment variables. +# +# Authors: +# Sorin Ionescu +# + +# Set the path to Oh My Zsh. +export OMZ="$HOME/.oh-my-zsh" + +# Paths +typeset -gU cdpath fpath mailpath manpath path +typeset -gUT INFOPATH infopath + +# Set the the list of directories that cd searches. +# cdpath=( +# $cdpath +# ) + +# Set the list of directories that info searches for manuals. +infopath=( + /usr/local/share/info + /usr/share/info + $infopath +) + +# Set the list of directories that man searches for manuals. +manpath=( + /usr/local/share/man + /usr/share/man + $manpath +) + +for path_file in /etc/manpaths.d/*(.N); do + manpath+=($(<$path_file)) +done +unset path_file + +# Set the list of directories that Zsh searches for programs. +path=( + /usr/local/{bin,sbin} + /usr/{bin,sbin} + /{bin,sbin} + $path +) + +for path_file in /etc/paths.d/*(.N); do + path+=($(<$path_file)) +done +unset path_file + +# Language +if [[ -z "$LANG" ]]; then + eval "$(locale)" +fi + +# Editors +export EDITOR='nano' +export VISUAL='nano' +export PAGER='less' + +# Browser (Default) +if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' +fi + +# Less + +# Set the default Less options. +# Mouse-wheel scrolling has been disabled by -X (disable screen clearing). +# Remove -X and -F (exit if the content fits on one screen) to enable it. +export LESS='-F -g -i -M -R -S -w -X -z-4' + +# Set the Less input preprocessor. +if (( $+commands[lesspipe.sh] )); then + export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' +fi + diff --git a/templates/zshrc b/templates/zshrc index 160a80ac..9305f90d 100644 --- a/templates/zshrc +++ b/templates/zshrc @@ -5,9 +5,6 @@ # Sorin Ionescu # -# Set the path to Oh My Zsh. -export OMZ="$HOME/.oh-my-zsh" - # Set the key mapping style to 'emacs' or 'vi'. zstyle ':omz:module:editor' keymap 'emacs'