From 8ee6634c938165567b089fc0e15fdd68fa50b1f6 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Wed, 21 Aug 2013 13:31:38 +0200 Subject: [PATCH 01/63] Do not define $GEM_HOME Defining it breaks gems for all users who neither use RVM nor rbenv, but have a different default Ruby version nonetheless. Signed-off-by: Sorin Ionescu --- modules/ruby/init.zsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 0303d5a3..1f748098 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -23,14 +23,9 @@ elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then elif (( $+commands[rbenv] )); then eval "$(rbenv init - --no-rehash zsh)" -# Install local gems according to operating system conventions. +# Prepend local gems bin directories to PATH. else - if [[ "$OSTYPE" == darwin* ]]; then - export GEM_HOME="$HOME/Library/Ruby/Gems/1.8" - path=("$GEM_HOME/bin" $path) - else - path=($HOME/.gem/ruby/*/bin(N) $path) - fi + path=($HOME/.gem/ruby/*/bin(N) $path) fi # Return if requirements are not found. From e1e2c853921fac9a011e232225a2838dc36bfab6 Mon Sep 17 00:00:00 2001 From: Joseph Irwin Date: Tue, 27 Aug 2013 16:21:19 +0900 Subject: [PATCH 02/63] Use correct option for pacman search aliases --- modules/pacman/init.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index c6fdc451..bbbdcfb5 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -55,10 +55,10 @@ alias pacq='pacman --sync --info' alias pacQ='pacman --query --info' # Searches for packages in the repositories. -alias pacs='pacman --sync --recursive' +alias pacs='pacman --sync --search' # Searches for packages in the local database. -alias pacS='pacman --query --recursive' +alias pacS='pacman --query --search' # Lists orphan packages. alias pacman-list-orphans='sudo pacman --query --deps --unrequired' From a914a87aa91147709306a8ee4206928587a98dd4 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 27 Aug 2013 22:22:55 -0400 Subject: [PATCH 03/63] Stop module loading when external code fails to source --- modules/history-substring-search/init.zsh | 2 +- modules/syntax-highlighting/init.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/history-substring-search/init.zsh b/modules/history-substring-search/init.zsh index 53eb99be..0fc191d8 100644 --- a/modules/history-substring-search/init.zsh +++ b/modules/history-substring-search/init.zsh @@ -10,7 +10,7 @@ pmodload 'editor' # Source module files. -source "${0:h}/external/zsh-history-substring-search.zsh" +source "${0:h}/external/zsh-history-substring-search.zsh" || return 1 # # Search diff --git a/modules/syntax-highlighting/init.zsh b/modules/syntax-highlighting/init.zsh index e5c555bd..55172b89 100644 --- a/modules/syntax-highlighting/init.zsh +++ b/modules/syntax-highlighting/init.zsh @@ -11,7 +11,7 @@ if ! zstyle -t ':prezto:module:syntax-highlighting' color; then fi # Source module files. -source "${0:h}/external/zsh-syntax-highlighting.zsh" +source "${0:h}/external/zsh-syntax-highlighting.zsh" || return 1 # Set highlighters. zstyle -a ':prezto:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS' From eb1a20552a9f53d5a1403be7a1f2485299d7d14b Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 27 Aug 2013 22:29:20 -0400 Subject: [PATCH 04/63] Comment an unnecessary style --- runcoms/zpreztorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index ee5aa0d3..8cdb163b 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -10,7 +10,7 @@ # # Set case-sensitivity for completion, history lookup, etc. -zstyle ':prezto:*:*' case-sensitive 'no' +# zstyle ':prezto:*:*' case-sensitive 'yes' # Color output (auto set to 'no' on dumb terminals). zstyle ':prezto:*:*' color 'yes' From aacff80984a4445bfd7be89201e32d6b10827c89 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 26 Sep 2013 14:06:54 -0400 Subject: [PATCH 05/63] [Fix #477] Add instructions for updating Prezto --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d076cc89..326b7354 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,13 @@ If you are not able to find certain commands after switching to *Prezto*, modify the `PATH` variable in *~/.zshenv* then open a new Zsh terminal window or tab. +Updating +-------- + +Pull the latest changes and update submodules. + + git pull && git submodule update --init --recursive + Usage ----- From a4bacb8bb9293d55db3afe1542e97ec7d964011a Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 26 Sep 2013 14:46:21 -0400 Subject: [PATCH 06/63] [Fix #479] Start only one ssh-agent instance --- modules/ssh/init.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index 320f7635..daa4372f 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -21,10 +21,13 @@ _ssh_agent_sock="$TMPDIR/ssh-agent.sock" # Start ssh-agent if not started. if [[ ! -S "$SSH_AUTH_SOCK" ]]; then - eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" -else # Export environment variables. source "$_ssh_agent_env" 2> /dev/null + + # Start ssh-agent if not started. + if ! ps -U "$USER" -o pid,ucomm | grep -q "${SSH_AGENT_PID} ssh-agent"; then + eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" + fi fi # Create a persistent SSH authentication socket. From e18f18af92bbe6d5a89cbb86dc43b9012c57a70d Mon Sep 17 00:00:00 2001 From: Daniel Renninghoff Date: Tue, 1 Oct 2013 16:06:57 +0200 Subject: [PATCH 07/63] Support command-not-found on Arch Linux Signed-off-by: Sorin Ionescu --- modules/command-not-found/README.md | 3 ++- modules/command-not-found/init.zsh | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/command-not-found/README.md b/modules/command-not-found/README.md index 91a67f25..691806a4 100644 --- a/modules/command-not-found/README.md +++ b/modules/command-not-found/README.md @@ -1,7 +1,8 @@ Command-Not-Found ================= -Loads the [command-not-found][1] tool on Debian-based distributions. +Displays installation information for not found commands by loading the +[command-not-found][1] tool on Debian-based and Arch Linux-based distributions. Authors ------- diff --git a/modules/command-not-found/init.zsh b/modules/command-not-found/init.zsh index 7b554e86..c4d1b9f9 100644 --- a/modules/command-not-found/init.zsh +++ b/modules/command-not-found/init.zsh @@ -5,10 +5,14 @@ # Joseph Jon Booker # +# Load command-not-found on Debian-based distributions. +if [[ -s '/etc/zsh_command_not_found' ]]; then + source '/etc/zsh_command_not_found' +# Load command-not-found on Arch Linux-based distributions. +elif [[ -s '/usr/share/doc/pkgfile/command-not-found.zsh' ]]; then + source '/usr/share/doc/pkgfile/command-not-found.zsh' # Return if requirements are not found. -if [[ ! -s '/etc/zsh_command_not_found' ]]; then +else return 1 fi -source '/etc/zsh_command_not_found' - From 1c6a01664463452edb9d1d83e4e291e4ff9071f3 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Mon, 14 Oct 2013 11:12:34 +0200 Subject: [PATCH 08/63] Add Ocaml module Manage local Ocaml modules with OPAM. Signed-off-by: Sorin Ionescu --- modules/README.md | 5 +++++ modules/ocaml/README.md | 28 ++++++++++++++++++++++++++++ modules/ocaml/init.zsh | 15 +++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 modules/ocaml/README.md create mode 100644 modules/ocaml/init.zsh diff --git a/modules/README.md b/modules/README.md index 63484e4c..3886dfc9 100644 --- a/modules/README.md +++ b/modules/README.md @@ -86,6 +86,11 @@ Node.js Provides utility functions for Node.js and loads npm completion. +Ocaml +----- + +Initializes Ocaml package management. + OSX --- diff --git a/modules/ocaml/README.md b/modules/ocaml/README.md new file mode 100644 index 00000000..7d56fec8 --- /dev/null +++ b/modules/ocaml/README.md @@ -0,0 +1,28 @@ +Ocaml +===== + +Initializes [Ocaml][1] package management. + +OPAM +---- + +[OPAM][2] is a package manager for Ocaml. + +This module enables local package installation with OPAM by extending the +relevant path and Ocaml variables. + +### Usage + +Install packages to your local package directory with `opam install`. + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][3].* + + - [Sebastian Wiesner](https://github.com/lunaryorn) + +[1]: http://ocaml.org/ +[2]: http://opam.ocamlpro.com/ +[3]: https://github.com/sorin-ionescu/prezto/issues + diff --git a/modules/ocaml/init.zsh b/modules/ocaml/init.zsh new file mode 100644 index 00000000..2e5b71e5 --- /dev/null +++ b/modules/ocaml/init.zsh @@ -0,0 +1,15 @@ +# +# Initializes Ocaml package management. +# +# Authors: +# Sebastian Wiesner +# + +# Return if requirements are not found. +if (( ! $+commands[opam] )); then + return 1 +fi + +# Initialize OPAM. +eval "$(opam config env)" + From 28e956691ca727ab4ae1bdbf73cc631a9f905527 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 17 Nov 2013 15:58:53 -0500 Subject: [PATCH 09/63] Add and update module descriptions --- modules/README.md | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/README.md b/modules/README.md index 3886dfc9..42583980 100644 --- a/modules/README.md +++ b/modules/README.md @@ -31,6 +31,16 @@ Dpkg Defines dpkg aliases and functions. +Editor +------ + +Sets key bindings. + +Emacs +----- + +Enables Emacs dependency management. + Environment ----------- @@ -41,13 +51,19 @@ Fasd Maintains a frequently used file and directory list for fast access. +Git +--- + +Enhances the Git distributed version control system by providing aliases, +functions and by exposing repository status information to prompts. + GNU Utility ----------- Provides for the interactive use of GNU utilities on non-GNU systems. GPG ---------- +--- Provides for an easier use of GPG by setting up gpg-agent. @@ -61,16 +77,16 @@ Helper Provides helper functions for developing modules. -History Substring Search ------------------------- - -Integrates zsh-history-substring-search into Prezto. - History ------- Sets history options and defines history aliases. +History Substring Search +------------------------ + +Integrates zsh-history-substring-search into Prezto. + Homebrew -------- @@ -142,10 +158,10 @@ Spectrum Provides for easier use of 256 colors and effects. -SSH-Agent ---------- +SSH +--- -Provides for an easier use of ssh-agent. +Provides for an easier use of SSH by setting up ssh-agent. Syntax Highlighting ------------------- From 8993a8dfadd2e090758bf41977938e91becc264e Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 20 Nov 2013 09:43:36 -0500 Subject: [PATCH 10/63] Bump minimum supported Zsh to v4.3.11 --- README.md | 2 +- init.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 326b7354..494a3a2b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Installation ------------ Prezto will work with any recent release of Zsh, but the minimum recommended -version is 4.3.10. +version is 4.3.11. 1. Launch Zsh: diff --git a/init.zsh b/init.zsh index fc12297c..fde7bcd3 100644 --- a/init.zsh +++ b/init.zsh @@ -10,7 +10,7 @@ # # Check for the minimum supported version. -min_zsh_version='4.3.10' +min_zsh_version='4.3.11' if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then print "prezto: old shell detected, minimum required: $min_zsh_version" >&2 return 1 From 3a5fff9c6d8e62032f0173476aed73afcd00578e Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 23 Nov 2013 04:23:56 -0800 Subject: [PATCH 11/63] Don't override customized environments in subshells Only set up environment for the top-level shell, and allow it to be inherited normally. A top level shell is usually a login shell, but can also be a non-interactive, non-login shell in certain cases, such as when executing an SSH remote command. Signed-off-by: Sorin Ionescu --- runcoms/zprofile | 69 +++++++++++++++++++++++++++++++++++++++++++++++ runcoms/zshenv | 70 +++--------------------------------------------- 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/runcoms/zprofile b/runcoms/zprofile index 2a3d07e6..642a5c74 100644 --- a/runcoms/zprofile +++ b/runcoms/zprofile @@ -5,3 +5,72 @@ # Sorin Ionescu # +# +# Browser +# + +if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' +fi + +# +# Editors +# + +export EDITOR='nano' +export VISUAL='nano' +export PAGER='less' + +# +# Language +# + +if [[ -z "$LANG" ]]; then + export LANG='en_US.UTF-8' +fi + +# +# Paths +# + +typeset -gU cdpath fpath mailpath path + +# Set the the list of directories that cd searches. +# cdpath=( +# $cdpath +# ) + +# Set the list of directories that Zsh searches for programs. +path=( + /usr/local/{bin,sbin} + $path +) + +# +# 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 + +# +# Temporary Files +# + +if [[ ! -d "$TMPDIR" ]]; then + export TMPDIR="/tmp/$USER" + mkdir -p -m 700 "$TMPDIR" +fi + +TMPPREFIX="${TMPDIR%/}/zsh" +if [[ ! -d "$TMPPREFIX" ]]; then + mkdir -p "$TMPPREFIX" +fi + diff --git a/runcoms/zshenv b/runcoms/zshenv index 9ff39e06..7b121203 100644 --- a/runcoms/zshenv +++ b/runcoms/zshenv @@ -5,72 +5,8 @@ # Sorin Ionescu # -# -# Browser -# - -if [[ "$OSTYPE" == darwin* ]]; then - export BROWSER='open' -fi - -# -# Editors -# - -export EDITOR='nano' -export VISUAL='nano' -export PAGER='less' - -# -# Language -# - -if [[ -z "$LANG" ]]; then - export LANG='en_US.UTF-8' -fi - -# -# Paths -# - -typeset -gU cdpath fpath mailpath path - -# Set the the list of directories that cd searches. -# cdpath=( -# $cdpath -# ) - -# Set the list of directories that Zsh searches for programs. -path=( - /usr/local/{bin,sbin} - $path -) - -# -# 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 - -# -# Temporary Files -# - -if [[ ! -d "$TMPDIR" ]]; then - export TMPDIR="/tmp/$USER" - mkdir -p -m 700 "$TMPDIR" -fi - -TMPPREFIX="${TMPDIR%/}/zsh" -if [[ ! -d "$TMPPREFIX" ]]; then - mkdir -p "$TMPPREFIX" +# Ensure that a non-login, non-interactive shell has a defined environment. +if [[ "$SHLVL" -eq 1 && ! -o LOGIN ]]; then + source "${ZDOTDIR:-$HOME}/.zprofile" fi From cc4a58bee331e44d3ef69e9b0eb43dea45267f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Str=C3=B6mberg?= Date: Sun, 24 Nov 2013 03:14:23 +0100 Subject: [PATCH 12/63] Add Rails 4 bin path --- modules/rails/init.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/rails/init.zsh b/modules/rails/init.zsh index e51185bb..4ddbd1b9 100644 --- a/modules/rails/init.zsh +++ b/modules/rails/init.zsh @@ -38,6 +38,8 @@ alias rorx='_rails-command destroy' function _rails-command { if [[ -e "script/server" ]]; then ruby script/"$@" + elif [[ -e "bin/rails" ]]; then + ruby bin/rails "$@" else ruby script/rails "$@" fi From 5cfe250e522ced205ef20989a892d65e82c7e2c4 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 25 Nov 2013 16:11:08 -0500 Subject: [PATCH 13/63] Rewrite _rails-command to work from app subdirectories --- modules/rails/init.zsh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/rails/init.zsh b/modules/rails/init.zsh index 4ddbd1b9..69f5b886 100644 --- a/modules/rails/init.zsh +++ b/modules/rails/init.zsh @@ -36,12 +36,27 @@ alias rorx='_rails-command destroy' # function _rails-command { - if [[ -e "script/server" ]]; then - ruby script/"$@" - elif [[ -e "bin/rails" ]]; then - ruby bin/rails "$@" + local root_dir="$PWD" + local rails_cmd + + while [[ "$root_dir" != '/' ]]; do + if [[ -d "$root_dir/.bundle" ]]; then + break + fi + root_dir="$root_dir:h" + done + + if [[ -e "$root_dir/bin/rails" ]]; then + rails_cmd='bin/rails' + elif [[ -e "$root_dir/script/rails" ]]; then + rails_cmd='script/rails' + elif [[ -e "$root_dir/script/server" ]]; then + rails_cmd='script/' else - ruby script/rails "$@" + print "$0: not inside of a Rails application: $PWD" >&2 + return 1 fi + + (cd "$root_dir" && ruby "$rails_cmd" "$@") } From b159ddb02ba9a630e2aa3ff29b3d5d4dace17705 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 25 Nov 2013 16:32:45 -0500 Subject: [PATCH 14/63] Do not specify a bundler install path --- modules/ruby/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 1f748098..6bf1ea53 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -44,7 +44,7 @@ alias rb='ruby' if (( $+commands[bundle] )); then alias rbb='bundle' alias rbbe='rbb exec' - alias rbbi='rbb install --path vendor/bundle' + alias rbbi='rbb install' alias rbbl='rbb list' alias rbbo='rbb open' alias rbbp='rbb package' From 52ea7152ad7ae4892dcf7e3b316b236786ba987b Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 25 Nov 2013 16:34:11 -0500 Subject: [PATCH 15/63] Git ignore bundler vendor/assets --- modules/ruby/init.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 6bf1ea53..e3238550 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -52,6 +52,8 @@ if (( $+commands[bundle] )); then alias rbbI='rbbi \ && rbb package \ && print .bundle >>! .gitignore \ + && print vendor/assets >>! .gitignore \ && print vendor/bundle >>! .gitignore \ && print vendor/cache >>! .gitignore' fi + From 76fc07ba9faa12419496ed77b380c102538f3bb3 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 25 Nov 2013 18:16:36 -0500 Subject: [PATCH 16/63] Comment a typeset --- runcoms/zprofile | 1 + 1 file changed, 1 insertion(+) diff --git a/runcoms/zprofile b/runcoms/zprofile index 642a5c74..7118770c 100644 --- a/runcoms/zprofile +++ b/runcoms/zprofile @@ -33,6 +33,7 @@ fi # Paths # +# Ensure path arrays do not contain duplicates. typeset -gU cdpath fpath mailpath path # Set the the list of directories that cd searches. From d87761773426d63f442d48c669a49a54151a1c99 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 28 Feb 2013 19:22:16 -0500 Subject: [PATCH 17/63] [Fix #362, Fix #384] Set Mac OS X 10.6 terminal window title --- modules/terminal/init.zsh | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index dc78a3be..e21aeb58 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -39,14 +39,13 @@ function set-terminal-tab-title { fi } +# Sets the Terminal.app current working directory. +function set-terminal-app-cwd { + printf '\e]7;%s\a' "file://$HOST${PWD// /%20}" +} + # Sets the tab and window titles with a given command. function set-titles-with-command { - # Do not set the window and tab titles in Terminal.app because they are not - # reset upon command termination. - if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then - return 1 - fi - emulate -L zsh setopt EXTENDED_GLOB @@ -85,26 +84,35 @@ function set-titles-with-path { setopt EXTENDED_GLOB local absolute_path="${${1:a}:-$PWD}" + local abbreviated_path="${absolute_path/#$HOME/~}" + local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" + unset MATCH - if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then - printf '\e]7;%s\a' "file://$HOST${absolute_path// /%20}" + if [[ "$TERM" == screen* ]]; then + set-screen-window-title "$truncated_path" else - local abbreviated_path="${absolute_path/#$HOME/~}" - local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" - unset MATCH - - if [[ "$TERM" == screen* ]]; then - set-screen-window-title "$truncated_path" - else - set-terminal-window-title "$abbreviated_path" - set-terminal-tab-title "$truncated_path" - fi + set-terminal-window-title "$abbreviated_path" + set-terminal-tab-title "$truncated_path" fi } # Don't override precmd/preexec; append to hook array. autoload -Uz add-zsh-hook +if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then + # Sets the Terminal.app current working directory. + add-zsh-hook precmd set-terminal-app-cwd + + # Do not set the tab and window titles in Terminal.app since it sets the tab + # title to the currently running process by default and the current working + # directory is set separately. + + # Do set the tab and window titles inside terminal multiplexers. + if [[ "$TERM" != screen* ]]; then + return + fi +fi + # Sets the tab and window titles before the prompt is displayed. function set-titles-precmd { if zstyle -t ':prezto:module:terminal' auto-title; then From f6bd76a90be8ad5077dc70e7291e55889f6cc6cb Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 20 Aug 2013 11:22:47 -0400 Subject: [PATCH 18/63] Remove unused GNU Screen window number format --- modules/terminal/init.zsh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index e21aeb58..c5b9dd3d 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -11,13 +11,6 @@ if [[ "$TERM" == 'dumb' ]]; then return 1 fi -# Set the GNU Screen window number. -if [[ -n "$WINDOW" ]]; then - export SCREEN_NO="%B${WINDOW}%b " -else - export SCREEN_NO="" -fi - # Sets the GNU Screen title. function set-screen-window-title { if [[ "$TERM" == screen* ]]; then From b98c7469e5026c55efa48cdacd4923ca54e8b098 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 26 Aug 2013 12:12:44 -0400 Subject: [PATCH 19/63] Rewrite terminal auto-title --- modules/helper/README.md | 2 ++ modules/helper/init.zsh | 5 +++ modules/terminal/README.md | 9 +++-- modules/terminal/init.zsh | 72 ++++++++++++++++++++++++-------------- runcoms/zpreztorc | 8 +++-- 5 files changed, 64 insertions(+), 32 deletions(-) diff --git a/modules/helper/README.md b/modules/helper/README.md index b010b005..7cafc2c6 100644 --- a/modules/helper/README.md +++ b/modules/helper/README.md @@ -11,6 +11,8 @@ Functions - `is-autoloadable` checks if a file can be autoloaded by trying to load it in a subshell. - `is-callable` checks if a name is a command, function, or alias. + - `is-terminal-inside-multiplexer` checks if the currently running terminal is + inside a terminal multiplexer. - `is-true` checks a boolean variable for "true". - `coalesce` prints the first non-empty string in the arguments array. diff --git a/modules/helper/init.zsh b/modules/helper/init.zsh index 7e0f9d57..b7a89aeb 100644 --- a/modules/helper/init.zsh +++ b/modules/helper/init.zsh @@ -21,6 +21,11 @@ function is-true { [[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]] } +# Checks if the currently running terminal is inside a terminal multiplexer. +function is-terminal-inside-multiplexer { + [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] +} + # Prints the first non-empty string in the arguments array. function coalesce { for arg in $argv; do diff --git a/modules/terminal/README.md b/modules/terminal/README.md index f1256c69..c1158b1c 100644 --- a/modules/terminal/README.md +++ b/modules/terminal/README.md @@ -8,10 +8,15 @@ Settings ### Auto-Title -To auto set the terminal window and tab titles with the current command or +To auto set the terminal emulator window and tab titles with the current command +or directory, add the following to *zpreztorc*: + + zstyle ':prezto:module:terminal:auto-title' emulator 'yes' + +To auto set the terminal multiplexer window title with the current command or directory, add the following to *zpreztorc*: - zstyle ':prezto:module:terminal' auto-title 'yes' + zstyle ':prezto:module:terminal:auto-title' multiplexer 'yes' Functions --------- diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index c5b9dd3d..8c46eb00 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -6,6 +6,9 @@ # Sorin Ionescu # +# Load dependencies. +pmodload 'helper' + # Return if requirements are not found. if [[ "$TERM" == 'dumb' ]]; then return 1 @@ -20,21 +23,23 @@ function set-screen-window-title { # Sets the terminal window title. function set-terminal-window-title { - if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then + if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*|dvtm*) ]]; then printf "\e]2;%s\a" ${(V)argv} fi } # Sets the terminal tab title. function set-terminal-tab-title { - if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then + if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*|dvtm*) ]]; then printf "\e]1;%s\a" ${(V)argv} fi } # Sets the Terminal.app current working directory. function set-terminal-app-cwd { - printf '\e]7;%s\a' "file://$HOST${PWD// /%20}" + if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then + printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" + fi } # Sets the tab and window titles with a given command. @@ -89,36 +94,49 @@ function set-titles-with-path { fi } -# Don't override precmd/preexec; append to hook array. +# Do not override precmd/preexec; append to the hook array. autoload -Uz add-zsh-hook -if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then - # Sets the Terminal.app current working directory. +# Set up the Apple Terminal. +if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \ + && (( ${${OSTYPE#darwin}[1,2]} >= 11 )) \ + && ! is-terminal-inside-multiplexer +then + # Sets the Terminal.app current working directory before the prompt is + # displayed. add-zsh-hook precmd set-terminal-app-cwd + # Unsets the Terminal.app current working directory when a terminal + # multiplexer or remote connection is started since it can no longer be + # updated, and it becomes confusing when the directory displayed in the title + # bar is no longer synchronized with real current working directory. + function unset-terminal-app-cwd { + if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then + set-terminal-app-cwd ' ' + fi + } + add-zsh-hook preexec unset-terminal-app-cwd + # Do not set the tab and window titles in Terminal.app since it sets the tab # title to the currently running process by default and the current working - # directory is set separately. - - # Do set the tab and window titles inside terminal multiplexers. - if [[ "$TERM" != screen* ]]; then - return - fi + # directory is set separately, but do set the tab and window titles inside + # terminal multiplexers inside Terminal.app. + return fi -# Sets the tab and window titles before the prompt is displayed. -function set-titles-precmd { - if zstyle -t ':prezto:module:terminal' auto-title; then - set-titles-with-path - fi -} -add-zsh-hook precmd set-titles-precmd - -# Sets the tab and window titles before command execution. -function set-titles-preexec { - if zstyle -t ':prezto:module:terminal' auto-title; then - set-titles-with-command "$2" - fi -} -add-zsh-hook preexec set-titles-preexec +# Set up non-Apple terminals. +if ( ( ! is-terminal-inside-multiplexer || [[ -n "$DVTM" ]] ) \ + && zstyle -t ':prezto:module:terminal:auto-title' emulator ) \ + || ( is-terminal-inside-multiplexer \ + && zstyle -t ':prezto:module:terminal:auto-title' multiplexer ) +then + # Sets the tab and window titles before the prompt is displayed. + add-zsh-hook precmd set-titles-with-path + + # Sets the tab and window titles before command execution. + function set-titles-with-command-preexec { + set-titles-with-command "$2" + } + add-zsh-hook preexec set-titles-with-command-preexec +fi diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 8cdb163b..0fde4bd4 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -122,14 +122,16 @@ zstyle ':prezto:module:prompt' theme 'sorin' # 'builtin' 'bg=blue' \ # 'command' 'bg=blue' \ # 'function' 'bg=blue' -# # # Terminal # -# Auto set the tab and window titles. -zstyle ':prezto:module:terminal' auto-title 'yes' +# Auto set the terminal emulator tab and window titles. +zstyle ':prezto:module:terminal:auto-title' emulator 'yes' + +# Auto set the terminal multiplexer window title. +zstyle ':prezto:module:terminal:auto-title' multiplexer 'no' # # Tmux From 5b4dcea595371bcf9c1018156c4a085d67c9b929 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 27 Aug 2013 15:53:49 -0400 Subject: [PATCH 20/63] Simplify auto-titling --- modules/helper/README.md | 2 - modules/helper/init.zsh | 5 --- modules/terminal/README.md | 22 ++++------ modules/terminal/init.zsh | 86 +++++++++++++------------------------- runcoms/zpreztorc | 7 +--- 5 files changed, 39 insertions(+), 83 deletions(-) diff --git a/modules/helper/README.md b/modules/helper/README.md index 7cafc2c6..b010b005 100644 --- a/modules/helper/README.md +++ b/modules/helper/README.md @@ -11,8 +11,6 @@ Functions - `is-autoloadable` checks if a file can be autoloaded by trying to load it in a subshell. - `is-callable` checks if a name is a command, function, or alias. - - `is-terminal-inside-multiplexer` checks if the currently running terminal is - inside a terminal multiplexer. - `is-true` checks a boolean variable for "true". - `coalesce` prints the first non-empty string in the arguments array. diff --git a/modules/helper/init.zsh b/modules/helper/init.zsh index b7a89aeb..7e0f9d57 100644 --- a/modules/helper/init.zsh +++ b/modules/helper/init.zsh @@ -21,11 +21,6 @@ function is-true { [[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]] } -# Checks if the currently running terminal is inside a terminal multiplexer. -function is-terminal-inside-multiplexer { - [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] -} - # Prints the first non-empty string in the arguments array. function coalesce { for arg in $argv; do diff --git a/modules/terminal/README.md b/modules/terminal/README.md index c1158b1c..76ce1c74 100644 --- a/modules/terminal/README.md +++ b/modules/terminal/README.md @@ -8,32 +8,26 @@ Settings ### Auto-Title -To auto set the terminal emulator window and tab titles with the current command -or directory, add the following to *zpreztorc*: - - zstyle ':prezto:module:terminal:auto-title' emulator 'yes' - -To auto set the terminal multiplexer window title with the current command or +To auto set the terminal window and tab titles with the current command or directory, add the following to *zpreztorc*: - zstyle ':prezto:module:terminal:auto-title' multiplexer 'yes' + zstyle ':prezto:module:terminal' auto-title 'yes' + +Auto titling is disabled inside terminal multiplexers, except inside dvtm, since +it interferes with window names defined in configuration files and profile +managers. Functions --------- -- `set-screen-window-title` sets the screen title. -- `set-terminal-tab-title` sets the terminal tab title. -- `set-terminal-window-title` sets the terminal window title. -- `set-titles-with-command` sets the screen and terminal titles with - a given command. -- `set-titles-with-path` sets the screen and terminal titles with a given path. +- `set-tab-title` sets the terminal tab title. +- `set-window-title` sets the terminal or terminal multiplexer window title. Authors ------- *The authors of this module should be contacted via the [issue tracker][1].* - - [James Cox](https://github.com/imajes) - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index 8c46eb00..b722a67f 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -2,82 +2,60 @@ # Sets terminal window and tab titles. # # Authors: -# James Cox # Sorin Ionescu # -# Load dependencies. -pmodload 'helper' - # Return if requirements are not found. if [[ "$TERM" == 'dumb' ]]; then return 1 fi -# Sets the GNU Screen title. -function set-screen-window-title { +# Sets the terminal or terminal multiplexer window title. +function set-window-title { if [[ "$TERM" == screen* ]]; then printf "\ek%s\e\\" ${(V)argv} - fi -} - -# Sets the terminal window title. -function set-terminal-window-title { - if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*|dvtm*) ]]; then + else printf "\e]2;%s\a" ${(V)argv} fi } # Sets the terminal tab title. -function set-terminal-tab-title { - if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*|dvtm*) ]]; then - printf "\e]1;%s\a" ${(V)argv} - fi -} - -# Sets the Terminal.app current working directory. -function set-terminal-app-cwd { - if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then - printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" - fi +function set-tab-title { + printf "\e]1;%s\a" ${(V)argv} } # Sets the tab and window titles with a given command. -function set-titles-with-command { +function set-titles-with-command-preexec { emulate -L zsh setopt EXTENDED_GLOB # Get the command name that is under job control. - if [[ "${1[(w)1]}" == (fg|%*)(\;|) ]]; then + if [[ "${2[(w)1]}" == (fg|%*)(\;|) ]]; then # Get the job name, and, if missing, set it to the default %+. - local job_name="${${1[(wr)%*(\;|)]}:-%+}" + local job_name="${${2[(wr)%*(\;|)]}:-%+}" # Make a local copy for use in the subshell. local -A jobtexts_from_parent_shell jobtexts_from_parent_shell=(${(kv)jobtexts}) - jobs $job_name 2>/dev/null > >( + jobs "$job_name" 2>/dev/null > >( read index discarded # The index is already surrounded by brackets: [1]. set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" ) else # Set the command name, or in the case of sudo or ssh, the next command. - local cmd=${${1[(wr)^(*=*|sudo|ssh|-*)]}:t} + local cmd="${${2[(wr)^(*=*|sudo|ssh|-*)]}:t}" local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}" unset MATCH - if [[ "$TERM" == screen* ]]; then - set-screen-window-title "$truncated_cmd" - else - set-terminal-window-title "$cmd" - set-terminal-tab-title "$truncated_cmd" - fi + set-window-title "$cmd" + set-tab-title "$truncated_cmd" fi } # Sets the tab and window titles with a given path. -function set-titles-with-path { +function set-titles-with-path-precmd { emulate -L zsh setopt EXTENDED_GLOB @@ -86,12 +64,13 @@ function set-titles-with-path { local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" unset MATCH - if [[ "$TERM" == screen* ]]; then - set-screen-window-title "$truncated_path" - else - set-terminal-window-title "$abbreviated_path" - set-terminal-tab-title "$truncated_path" - fi + set-window-title "$abbreviated_path" + set-tab-title "$truncated_path" +} + +# Sets the Terminal.app proxy icon. +function set-terminal-app-proxy-icon-precmd { + printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" } # Do not override precmd/preexec; append to the hook array. @@ -99,44 +78,37 @@ autoload -Uz add-zsh-hook # Set up the Apple Terminal. if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \ - && (( ${${OSTYPE#darwin}[1,2]} >= 11 )) \ - && ! is-terminal-inside-multiplexer + && ( ! [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] ) then # Sets the Terminal.app current working directory before the prompt is # displayed. - add-zsh-hook precmd set-terminal-app-cwd + add-zsh-hook precmd set-terminal-app-proxy-icon-precmd # Unsets the Terminal.app current working directory when a terminal # multiplexer or remote connection is started since it can no longer be # updated, and it becomes confusing when the directory displayed in the title # bar is no longer synchronized with real current working directory. - function unset-terminal-app-cwd { + function unset-terminal-app-proxy-icon-preexec { if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then - set-terminal-app-cwd ' ' + set-terminal-app-proxy-icon-precmd ' ' fi } - add-zsh-hook preexec unset-terminal-app-cwd + add-zsh-hook preexec unset-terminal-app-cwd-preexec # Do not set the tab and window titles in Terminal.app since it sets the tab # title to the currently running process by default and the current working - # directory is set separately, but do set the tab and window titles inside - # terminal multiplexers inside Terminal.app. + # directory is set separately. return fi # Set up non-Apple terminals. -if ( ( ! is-terminal-inside-multiplexer || [[ -n "$DVTM" ]] ) \ - && zstyle -t ':prezto:module:terminal:auto-title' emulator ) \ - || ( is-terminal-inside-multiplexer \ - && zstyle -t ':prezto:module:terminal:auto-title' multiplexer ) +if zstyle -t ':prezto:module:terminal' auto-title \ + && ( ! [[ -n "$STY" || -n "$TMUX" ]] ) then # Sets the tab and window titles before the prompt is displayed. - add-zsh-hook precmd set-titles-with-path + add-zsh-hook precmd set-titles-with-path-precmd # Sets the tab and window titles before command execution. - function set-titles-with-command-preexec { - set-titles-with-command "$2" - } add-zsh-hook preexec set-titles-with-command-preexec fi diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 0fde4bd4..b045cab9 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -127,11 +127,8 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Terminal # -# Auto set the terminal emulator tab and window titles. -zstyle ':prezto:module:terminal:auto-title' emulator 'yes' - -# Auto set the terminal multiplexer window title. -zstyle ':prezto:module:terminal:auto-title' multiplexer 'no' +# Auto set the tab and window titles. +# zstyle ':prezto:module:terminal' auto-title 'yes' # # Tmux From 9f60ddb96b041e820d6fb7b837dac227a2f81b0d Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 27 Aug 2013 16:04:52 -0400 Subject: [PATCH 21/63] Prefix internal functions --- modules/terminal/init.zsh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index b722a67f..0bd0ac31 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -25,7 +25,7 @@ function set-tab-title { } # Sets the tab and window titles with a given command. -function set-titles-with-command-preexec { +function _terminal-set-titles-with-command-preexec { emulate -L zsh setopt EXTENDED_GLOB @@ -55,7 +55,7 @@ function set-titles-with-command-preexec { } # Sets the tab and window titles with a given path. -function set-titles-with-path-precmd { +function _terminal-set-titles-with-path-precmd { emulate -L zsh setopt EXTENDED_GLOB @@ -69,7 +69,7 @@ function set-titles-with-path-precmd { } # Sets the Terminal.app proxy icon. -function set-terminal-app-proxy-icon-precmd { +function _terminal-set-terminal-app-proxy-icon-precmd { printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" } @@ -82,18 +82,18 @@ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \ then # Sets the Terminal.app current working directory before the prompt is # displayed. - add-zsh-hook precmd set-terminal-app-proxy-icon-precmd + add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon-precmd # Unsets the Terminal.app current working directory when a terminal # multiplexer or remote connection is started since it can no longer be # updated, and it becomes confusing when the directory displayed in the title # bar is no longer synchronized with real current working directory. - function unset-terminal-app-proxy-icon-preexec { + function _terminal-unset-terminal-app-proxy-icon-preexec { if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then - set-terminal-app-proxy-icon-precmd ' ' + _terminal-set-terminal-app-proxy-icon-precmd ' ' fi } - add-zsh-hook preexec unset-terminal-app-cwd-preexec + add-zsh-hook preexec _terminal-unset-terminal-app-proxy-icon-preexec # Do not set the tab and window titles in Terminal.app since it sets the tab # title to the currently running process by default and the current working @@ -106,9 +106,9 @@ if zstyle -t ':prezto:module:terminal' auto-title \ && ( ! [[ -n "$STY" || -n "$TMUX" ]] ) then # Sets the tab and window titles before the prompt is displayed. - add-zsh-hook precmd set-titles-with-path-precmd + add-zsh-hook precmd _terminal-set-titles-with-path-precmd # Sets the tab and window titles before command execution. - add-zsh-hook preexec set-titles-with-command-preexec + add-zsh-hook preexec _terminal-set-titles-with-command-preexec fi From d19c349f3feae7566bab59769e94021f3e96188f Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 28 Aug 2013 15:40:07 -0400 Subject: [PATCH 22/63] Unsufix internal functions --- modules/terminal/init.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index 0bd0ac31..d49fd153 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -25,7 +25,7 @@ function set-tab-title { } # Sets the tab and window titles with a given command. -function _terminal-set-titles-with-command-preexec { +function _terminal-set-titles-with-command { emulate -L zsh setopt EXTENDED_GLOB @@ -41,7 +41,7 @@ function _terminal-set-titles-with-command-preexec { jobs "$job_name" 2>/dev/null > >( read index discarded # The index is already surrounded by brackets: [1]. - set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" + _terminal-set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" ) else # Set the command name, or in the case of sudo or ssh, the next command. @@ -55,7 +55,7 @@ function _terminal-set-titles-with-command-preexec { } # Sets the tab and window titles with a given path. -function _terminal-set-titles-with-path-precmd { +function _terminal-set-titles-with-path { emulate -L zsh setopt EXTENDED_GLOB @@ -69,7 +69,7 @@ function _terminal-set-titles-with-path-precmd { } # Sets the Terminal.app proxy icon. -function _terminal-set-terminal-app-proxy-icon-precmd { +function _terminal-set-terminal-app-proxy-icon { printf '\e]7;%s\a' "file://$HOST${${1:-$PWD}// /%20}" } @@ -82,18 +82,18 @@ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \ then # Sets the Terminal.app current working directory before the prompt is # displayed. - add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon-precmd + add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon # Unsets the Terminal.app current working directory when a terminal # multiplexer or remote connection is started since it can no longer be # updated, and it becomes confusing when the directory displayed in the title # bar is no longer synchronized with real current working directory. - function _terminal-unset-terminal-app-proxy-icon-preexec { + function _terminal-unset-terminal-app-proxy-icon { if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then - _terminal-set-terminal-app-proxy-icon-precmd ' ' + _terminal-set-terminal-app-proxy-icon ' ' fi } - add-zsh-hook preexec _terminal-unset-terminal-app-proxy-icon-preexec + add-zsh-hook preexec _terminal-unset-terminal-app-proxy-icon # Do not set the tab and window titles in Terminal.app since it sets the tab # title to the currently running process by default and the current working @@ -106,9 +106,9 @@ if zstyle -t ':prezto:module:terminal' auto-title \ && ( ! [[ -n "$STY" || -n "$TMUX" ]] ) then # Sets the tab and window titles before the prompt is displayed. - add-zsh-hook precmd _terminal-set-titles-with-path-precmd + add-zsh-hook precmd _terminal-set-titles-with-path # Sets the tab and window titles before command execution. - add-zsh-hook preexec _terminal-set-titles-with-command-preexec + add-zsh-hook preexec _terminal-set-titles-with-command fi From 254b7c36d97a0fbe76ba81541e1f76f52120c841 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 28 Aug 2013 17:13:14 -0400 Subject: [PATCH 23/63] [Fix #324] Add configurable terminal window and tab title formats --- modules/terminal/README.md | 15 +++++++++++++-- modules/terminal/init.zsh | 16 +++++++++++++--- runcoms/zpreztorc | 6 ++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/terminal/README.md b/modules/terminal/README.md index 76ce1c74..435d9720 100644 --- a/modules/terminal/README.md +++ b/modules/terminal/README.md @@ -17,6 +17,16 @@ Auto titling is disabled inside terminal multiplexers, except inside dvtm, since it interferes with window names defined in configuration files and profile managers. +To format terminal window and tab titles, add the following to *zpreztorc*: + + zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' + zstyle ':prezto:module:terminal:tab-title' format '%m: %s' + +`%s` will be replaced with the current working directory path or the currently +executing program name. + +For a list of sequences, see [Expansion of Prompt Sequences][1]. + Functions --------- @@ -26,9 +36,10 @@ Functions Authors ------- -*The authors of this module should be contacted via the [issue tracker][1].* +*The authors of this module should be contacted via the [issue tracker][2].* - [Sorin Ionescu](https://github.com/sorin-ionescu) -[1]: https://github.com/sorin-ionescu/prezto/issues +[1]: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Expansion-of-Prompt-Sequences +[2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index d49fd153..eeca67e2 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -12,16 +12,26 @@ fi # Sets the terminal or terminal multiplexer window title. function set-window-title { + local title_format{,ted} + zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s" + zformat -f title_formatted "$title_format" "s:$argv" + if [[ "$TERM" == screen* ]]; then - printf "\ek%s\e\\" ${(V)argv} + title_format="\ek%s\e\\" else - printf "\e]2;%s\a" ${(V)argv} + title_format="\e]2;%s\a" fi + + printf "$title_format" "${(V%)title_formatted}" } # Sets the terminal tab title. function set-tab-title { - printf "\e]1;%s\a" ${(V)argv} + local title_format{,ted} + zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s" + zformat -f title_formatted "$title_format" "s:$argv" + + printf "\e]1;%s\a" ${(V%)title_formatted} } # Sets the tab and window titles with a given command. diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index b045cab9..9dd6c5dc 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -130,6 +130,12 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto set the tab and window titles. # zstyle ':prezto:module:terminal' auto-title 'yes' +# Set the window title format. +# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' + +# Set the tab title format. +# zstyle ':prezto:module:terminal:tab-title' format '%m: %s' + # # Tmux # From d368d0536b7e857b8bd98cb7f5f547bac8b96bac Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 27 Sep 2013 00:11:38 -0400 Subject: [PATCH 24/63] Remove utility aliases for Cygwin --- modules/utility/init.zsh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 91c78090..c1beee13 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -104,10 +104,6 @@ alias sl='ls' # I often screw this up. # Mac OS X Everywhere if [[ "$OSTYPE" == darwin* ]]; then alias o='open' -elif [[ "$OSTYPE" == cygwin* ]]; then - alias o='cygstart' - alias pbcopy='tee > /dev/clipboard' - alias pbpaste='cat /dev/clipboard' else alias o='xdg-open' From b1abe7a84538097bf93e2c6677cedc7d7a980f68 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 27 Sep 2013 00:19:04 -0400 Subject: [PATCH 25/63] Warn that Cygwin is not supported --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 494a3a2b..27076d96 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Installation ------------ Prezto will work with any recent release of Zsh, but the minimum recommended -version is 4.3.11. +version is 4.3.11. Unfortunately, [Cygwin][9] is not supported due to +non-standard core utilities. 1. Launch Zsh: @@ -113,4 +114,5 @@ SOFTWARE. [6]: http://gitref.org [7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf [8]: http://grml.org/zsh/zsh-lovers.html +[9]: http://www.cygwin.com From 50edc451323fb70f225dd02475d799bce17c8cac Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 27 Nov 2013 12:31:08 -0500 Subject: [PATCH 26/63] [Fix #503] Prefix rails aliases with 'bundle exec' --- modules/rails/init.zsh | 64 +++++++++------------------- modules/ruby/README.md | 1 + modules/ruby/functions/ruby-app-root | 19 +++++++++ 3 files changed, 39 insertions(+), 45 deletions(-) create mode 100644 modules/ruby/functions/ruby-app-root diff --git a/modules/rails/init.zsh b/modules/rails/init.zsh index 69f5b886..70f50ce8 100644 --- a/modules/rails/init.zsh +++ b/modules/rails/init.zsh @@ -7,56 +7,30 @@ # Sorin Ionescu # +# Load dependencies. +pmodload 'ruby' + # Return if requirements are not found. -if (( ! $+commands[rails] )); then +if (( ! $+commands[bundle] )); then return 1 fi # -# Aliases (Compatible with Rails 2) -# - -alias ror='rails' -alias rorc='_rails-command console' -alias rordc='_rails-command dbconsole' -alias rordm='rake db:migrate' -alias rordM='rake db:migrate db:test:clone' -alias rordr='rake db:rollback' -alias rorg='_rails-command generate' -alias rorl='tail -f log/development.log' -alias rorlc='rake log:clear' -alias rorp='_rails-command plugin' -alias rorr='_rails-command runner' -alias rors='_rails-command server' -alias rorsd='_rails-command server --debugger' -alias rorx='_rails-command destroy' - -# -# Functions +# Aliases # -function _rails-command { - local root_dir="$PWD" - local rails_cmd - - while [[ "$root_dir" != '/' ]]; do - if [[ -d "$root_dir/.bundle" ]]; then - break - fi - root_dir="$root_dir:h" - done - - if [[ -e "$root_dir/bin/rails" ]]; then - rails_cmd='bin/rails' - elif [[ -e "$root_dir/script/rails" ]]; then - rails_cmd='script/rails' - elif [[ -e "$root_dir/script/server" ]]; then - rails_cmd='script/' - else - print "$0: not inside of a Rails application: $PWD" >&2 - return 1 - fi - - (cd "$root_dir" && ruby "$rails_cmd" "$@") -} +alias ror='bundle exec rails' +alias rorc='bundle exec rails console' +alias rordc='bundle exec rails dbconsole' +alias rordm='bundle exec rake db:migrate' +alias rordM='bundle exec rake db:migrate db:test:clone' +alias rordr='bundle exec rake db:rollback' +alias rorg='bundle exec rails generate' +alias rorl='tail -f "$(ruby-app-root)/log/development.log"' +alias rorlc='bundle exec rake log:clear' +alias rorp='bundle exec rails plugin' +alias rorr='bundle exec rails runner' +alias rors='bundle exec rails server' +alias rorsd='bundle exec rails server --debugger' +alias rorx='bundle exec rails destroy' diff --git a/modules/ruby/README.md b/modules/ruby/README.md index 42e63be6..e78d7576 100644 --- a/modules/ruby/README.md +++ b/modules/ruby/README.md @@ -59,6 +59,7 @@ Aliases Functions --------- + - `ruby-app-root` displays the path to the Ruby application root directory. - `ruby-info` exposes information about the Ruby environment via the `$ruby_info` associative array. diff --git a/modules/ruby/functions/ruby-app-root b/modules/ruby/functions/ruby-app-root new file mode 100644 index 00000000..cff8966f --- /dev/null +++ b/modules/ruby/functions/ruby-app-root @@ -0,0 +1,19 @@ +# +# Displays the path to the Ruby application root directory. +# +# Authors: +# Sorin Ionescu +# + +local root_dir="$PWD" + +while [[ "$root_dir" != '/' ]]; do + if [[ -f "$root_dir/Gemfile" ]]; then + print "$root_dir" + break + fi + root_dir="$root_dir:h" +done + +return 1 + From cdc4f36f25d0f0c83bed963f6a768c93f46586a9 Mon Sep 17 00:00:00 2001 From: Peter Jaros Date: Fri, 29 Nov 2013 17:34:34 -0500 Subject: [PATCH 27/63] Fix heading level for "zpreztorc" --- runcoms/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runcoms/README.md b/runcoms/README.md index 74030b87..97824d8c 100644 --- a/runcoms/README.md +++ b/runcoms/README.md @@ -48,7 +48,7 @@ zprofile and zlogin are not meant to be used concurrently but can be done so. This file is sourced by interactive shells. It should define aliases, functions, shell options, and key bindings. -## zpreztorc +### zpreztorc This file configures Prezto. From a57d545639ce0ceb46a8cdfe8c1f51e52ee990dd Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 29 Nov 2013 19:13:06 -0500 Subject: [PATCH 28/63] Update copyright --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27076d96..5c5e9323 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ License (The MIT License) -Copyright (c) 2009-2012 Robby Russell, Sorin Ionescu, and contributors. +Copyright (c) 2009-2014 Sorin Ionescu and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 4e9553e896ab6e9344cc6d6f548ce16dbeed8e41 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 29 Nov 2013 20:36:07 -0500 Subject: [PATCH 29/63] Update external syntax-highlighting --- modules/syntax-highlighting/external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/syntax-highlighting/external b/modules/syntax-highlighting/external index dbd27cb3..f289a9f8 160000 --- a/modules/syntax-highlighting/external +++ b/modules/syntax-highlighting/external @@ -1 +1 @@ -Subproject commit dbd27cb30a710809dd070669c331574fdc15b397 +Subproject commit f289a9f8e7a8a1752cd88f2366e6dacf8a0036e7 From eea1eea7dc33577e2630214756cba4482d377017 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 29 Nov 2013 20:36:33 -0500 Subject: [PATCH 30/63] Update external history-substring-search --- modules/history-substring-search/external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/history-substring-search/external b/modules/history-substring-search/external index d9b28ed7..1e768040 160000 --- a/modules/history-substring-search/external +++ b/modules/history-substring-search/external @@ -1 +1 @@ -Subproject commit d9b28ed7f9c62d843c6f3e599ab4f3aa0bdd37b5 +Subproject commit 1e7680405239a835aa403a7457cad23750f98e72 From 2ebdbdcff5e20a95812bf8ee3762dd80cbf46239 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 29 Nov 2013 20:37:01 -0500 Subject: [PATCH 31/63] Update external completions --- modules/completion/external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/completion/external b/modules/completion/external index 662229f6..1d6a2aa0 160000 --- a/modules/completion/external +++ b/modules/completion/external @@ -1 +1 @@ -Subproject commit 662229f6f0ce391ef7c1a41c398e28a31e847182 +Subproject commit 1d6a2aa024ea159229b3cfa6942cadaab1961ace From da1a837cd41dd868973a6eefd8decd4d38d96e27 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 30 Nov 2013 19:25:11 -0500 Subject: [PATCH 32/63] Refactor Bundler aliases --- modules/ruby/init.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index e3238550..89b1345a 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -43,14 +43,14 @@ alias rb='ruby' # Bundler if (( $+commands[bundle] )); then alias rbb='bundle' - alias rbbe='rbb exec' - alias rbbi='rbb install' - alias rbbl='rbb list' - alias rbbo='rbb open' - alias rbbp='rbb package' - alias rbbu='rbb update' + alias rbbe='bundle exec' + alias rbbi='bundle install --path vendor/bundle' + alias rbbl='bundle list' + alias rbbo='bundle open' + alias rbbp='bundle package' + alias rbbu='bundle update' alias rbbI='rbbi \ - && rbb package \ + && bundle package \ && print .bundle >>! .gitignore \ && print vendor/assets >>! .gitignore \ && print vendor/bundle >>! .gitignore \ From 347928193fc0a85ea7b06f71b39c051daa031493 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 6 Dec 2013 17:13:36 -0500 Subject: [PATCH 33/63] Update copyright --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c5e9323..3409e17e 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,8 @@ License (The MIT License) -Copyright (c) 2009-2014 Sorin Ionescu and contributors. +Copyright (c) 2009-2011 Robby Russell and contributors. +Copyright (c) 2011-2014 Sorin Ionescu and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 817dd3aa3aeba2d92af5860ffed1d6ee2377eaff Mon Sep 17 00:00:00 2001 From: Caleb Land Date: Tue, 10 Dec 2013 18:49:43 -0500 Subject: [PATCH 34/63] Allow functions in a module to be symlinks Add the '-' flag to the function glob which makes the other flag test against the target of the symlink, and not the symlink itself. When using rcm (https://github.com/thoughtbot/rcm), the function files are symlinked by default, but the current glob excludes them by targeting normal files (with the '.' flag). Signed-off-by: Sorin Ionescu --- init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.zsh b/init.zsh index fde7bcd3..75adfe51 100644 --- a/init.zsh +++ b/init.zsh @@ -25,7 +25,7 @@ unset min_zsh_version function pmodload { local -a pmodules local pmodule - local pfunction_glob='^([_.]*|prompt_*_setup|README*)(.N:t)' + local pfunction_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)' # $argv is overridden in the anonymous function. pmodules=("$argv[@]") From e4e4f89c9fd4649263637051b4dfe4e22342243a Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 3 Jan 2014 13:37:36 -0500 Subject: [PATCH 35/63] [Fix #523] Ensure zprofile exists before sourcing it --- runcoms/zshenv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runcoms/zshenv b/runcoms/zshenv index 7b121203..2b13503a 100644 --- a/runcoms/zshenv +++ b/runcoms/zshenv @@ -6,7 +6,7 @@ # # Ensure that a non-login, non-interactive shell has a defined environment. -if [[ "$SHLVL" -eq 1 && ! -o LOGIN ]]; then +if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then source "${ZDOTDIR:-$HOME}/.zprofile" fi From aefdce3fc31955e6c24636c8d624731c9107d6d9 Mon Sep 17 00:00:00 2001 From: Julien Stechele Date: Tue, 17 Dec 2013 01:17:31 +0100 Subject: [PATCH 36/63] Fix README.md: PATH was moved from .zshenv to .zprofile --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3409e17e..8799ee43 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ non-standard core utilities. ### Troubleshooting If you are not able to find certain commands after switching to *Prezto*, -modify the `PATH` variable in *~/.zshenv* then open a new Zsh terminal +modify the `PATH` variable in *~/.zprofile* then open a new Zsh terminal window or tab. Updating From 57b283facd8594a48757d04be79ef882d84ad9e8 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 3 Jan 2014 14:20:32 -0500 Subject: [PATCH 37/63] [Fix #514] Use /tmp when $TMPDIR is undefined --- modules/gpg/init.zsh | 2 +- modules/pacman/functions/pacman-list-disowned | 2 +- modules/ssh/init.zsh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/gpg/init.zsh b/modules/gpg/init.zsh index 2e4c4eab..48f1715a 100644 --- a/modules/gpg/init.zsh +++ b/modules/gpg/init.zsh @@ -12,7 +12,7 @@ fi # Set the default paths to gpg-agent files. _gpg_agent_conf="$HOME/.gnupg/gpg-agent.conf" -_gpg_agent_env="$TMPDIR/gpg-agent.env" +_gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env" # Start gpg-agent if not started. if ! ps -U "$USER" -o ucomm | grep -q gpg-agent; then diff --git a/modules/pacman/functions/pacman-list-disowned b/modules/pacman/functions/pacman-list-disowned index 2cd8a92b..d6b6f289 100644 --- a/modules/pacman/functions/pacman-list-disowned +++ b/modules/pacman/functions/pacman-list-disowned @@ -6,7 +6,7 @@ # Sorin Ionescu # -local tmp="$TMPDIR/pacman-disowned-$UID-$$" +local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$" local db="$tmp/db" local fs="$tmp/fs" diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index daa4372f..608e34e6 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -14,10 +14,10 @@ fi _ssh_dir="$HOME/.ssh" # Set the path to the environment file if not set by another module. -_ssh_agent_env="${_ssh_agent_env:-$TMPDIR/ssh-agent.env}" +_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env}" # Set the path to the persistent authentication socket. -_ssh_agent_sock="$TMPDIR/ssh-agent.sock" +_ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock" # Start ssh-agent if not started. if [[ ! -S "$SSH_AUTH_SOCK" ]]; then From fa6723a5eef1811d68d6a43194ee23d573449757 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Mon, 9 Dec 2013 15:29:14 +0100 Subject: [PATCH 38/63] Don't use sudo if implicitly called by Pacman frontend Don't rely on alias expansion to handle Pacman because aliases are not expanded in sudo. Signed-off-by: Sorin Ionescu --- modules/pacman/init.zsh | 32 +++++++++++++++++--------------- modules/pacman/yaourt.zsh | 4 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index bbbdcfb5..8b9a4330 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -27,6 +27,8 @@ if (( $+commands[$_pacman_frontend] )); then if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then source "${0:h}/${_pacman_frontend}.zsh" fi +else + _pacman_sudo='sudo ' fi # @@ -34,49 +36,49 @@ fi # # Pacman. -alias pac='pacman' +alias pac= "${_pacman_frontend}" # Installs packages from repositories. -alias paci='sudo pacman --sync' +alias paci="${_pacman_sudo}${_pacman_frontend} --sync" # Installs packages from files. -alias pacI='sudo pacman --upgrade' +alias pacI="${_pacman_sudo}${_pacman_frontend} --upgrade" # Removes packages and unneeded dependencies. -alias pacx='sudo pacman --remove' +alias pacx="${_pacman_sudo}${_pacman_frontend} --remove" # Removes packages, their configuration, and unneeded dependencies. -alias pacX='sudo pacman --remove --nosave --recursive' +alias pacX="${_pacman_sudo}${_pacman_frontend} --remove --nosave --recursive" # Displays information about a package from the repositories. -alias pacq='pacman --sync --info' +alias pacq="${_pacman_frontend} --sync --info" # Displays information about a package from the local database. -alias pacQ='pacman --query --info' +alias pacQ="${_pacman_frontend} --query --info" # Searches for packages in the repositories. -alias pacs='pacman --sync --search' +alias pacs="${_pacman_frontend} --sync --search" # Searches for packages in the local database. -alias pacS='pacman --query --search' +alias pacS="${_pacman_frontend} --query --search" # Lists orphan packages. -alias pacman-list-orphans='sudo pacman --query --deps --unrequired' +alias pacman-list-orphans="${_pacman_sudo}${_pacman_frontend} --query --deps --unrequired" # Removes orphan packages. -alias pacman-remove-orphans='sudo pacman --remove --recursive $(pacman --quiet --query --deps --unrequired)' +alias pacman-remove-orphans="${_pacman_sudo}${_pacman_frontend} --remove --recursive \$(${_pacman_frontend} --quiet --query --deps --unrequired)" # Synchronizes the local package and Arch Build System databases against the # repositories. if (( $+commands[abs] )); then - alias pacu='sudo pacman --sync --refresh && sudo abs' + alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && ${_pacman_sudo}abs" else - alias pacu='sudo pacman --sync --refresh' + alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh" fi # Synchronizes the local package database against the repositories then # upgrades outdated packages. -alias pacU='sudo pacman --sync --refresh --sysupgrade' +alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade" -unset _pacman_frontend +unset _pacman_{frontend,sudo} diff --git a/modules/pacman/yaourt.zsh b/modules/pacman/yaourt.zsh index fb2a8dc2..f4709e08 100644 --- a/modules/pacman/yaourt.zsh +++ b/modules/pacman/yaourt.zsh @@ -11,9 +11,9 @@ # Disable color. if ! zstyle -t ':prezto:module:pacman:yaourt' color; then - alias pacman='pacman --nocolor' + alias pacman='yaourt --nocolor' fi # Manages .pac* files. -alias pacc='pacman -C' +alias pacc='yaourt -C' From 80ded5e33d9d7b583f51f8c9ef4392d612d64366 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 3 Jan 2014 14:46:30 -0500 Subject: [PATCH 39/63] Revert "Remove utility aliases for Cygwin" This reverts commit d368d0536b7e857b8bd98cb7f5f547bac8b96bac. --- modules/utility/init.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index c1beee13..91c78090 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -104,6 +104,10 @@ alias sl='ls' # I often screw this up. # Mac OS X Everywhere if [[ "$OSTYPE" == darwin* ]]; then alias o='open' +elif [[ "$OSTYPE" == cygwin* ]]; then + alias o='cygstart' + alias pbcopy='tee > /dev/clipboard' + alias pbpaste='cat /dev/clipboard' else alias o='xdg-open' From 391bc405d0378d092937f62944390b79edb13ad9 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 3 Jan 2014 14:46:35 -0500 Subject: [PATCH 40/63] Revert "Warn that Cygwin is not supported" This reverts commit b1abe7a84538097bf93e2c6677cedc7d7a980f68. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 8799ee43..24445cb5 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ Installation ------------ Prezto will work with any recent release of Zsh, but the minimum recommended -version is 4.3.11. Unfortunately, [Cygwin][9] is not supported due to -non-standard core utilities. +version is 4.3.11. 1. Launch Zsh: @@ -115,5 +114,4 @@ SOFTWARE. [6]: http://gitref.org [7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf [8]: http://grml.org/zsh/zsh-lovers.html -[9]: http://www.cygwin.com From e1974ad58db5efbc85e65c638703d54847540c79 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 9 Jan 2014 19:58:14 -0500 Subject: [PATCH 41/63] [Fix #516] Define ZLE functions separately --- modules/editor/init.zsh | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 0fe98858..9a347a09 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -107,31 +107,40 @@ function editor-info { } zle -N editor-info -# Ensures that $terminfo values are valid and updates editor information when -# the keymap changes. -function zle-keymap-select zle-line-init zle-line-finish { +# Updates editor information when the keymap changes. +function zle-keymap-select { + zle editor-info +} +zle -N zle-keymap-select + +# Enables terminal application mode and updates editor information. +function zle-line-init { # The terminal must be in application mode when ZLE is active for $terminfo # values to be valid. - if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then - case "$0" in - (zle-line-init) - # Enable terminal application mode. - echoti smkx - ;; - (zle-line-finish) - # Disable terminal application mode. - echoti rmkx - ;; - esac + if (( $+terminfo[smkx] )); then + # Enable terminal application mode. + echoti smkx fi # Update editor information. zle editor-info } -zle -N zle-keymap-select -zle -N zle-line-finish zle -N zle-line-init +# Disables terminal application mode and updates editor information. +function zle-line-finish { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[rmkx] )); then + # Disable terminal application mode. + echoti rmkx + fi + + # Update editor information. + zle editor-info +} +zle -N zle-line-finish + # Toggles emacs overwrite mode and updates editor information. function overwrite-mode { zle .overwrite-mode From c091f71283eb12fe71b42f01c365175b29ea4b36 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 9 Jan 2014 20:07:40 -0500 Subject: [PATCH 42/63] [Fix #522] Do not load the terminal module in non-graphical terminals --- modules/terminal/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index eeca67e2..e35b77db 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -6,7 +6,7 @@ # # Return if requirements are not found. -if [[ "$TERM" == 'dumb' ]]; then +if [[ "$TERM" == (dumb|linux|*bsd*) ]]; then return 1 fi From 839f4a7b83f253f2990170e825dbae48828ec997 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Mon, 13 Jan 2014 15:15:08 +0530 Subject: [PATCH 43/63] Fix setting the 'pac' alias --- modules/pacman/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index 8b9a4330..f42e0330 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -36,7 +36,7 @@ fi # # Pacman. -alias pac= "${_pacman_frontend}" +alias pac="${_pacman_frontend}" # Installs packages from repositories. alias paci="${_pacman_sudo}${_pacman_frontend} --sync" From af003d83c54018f47e2fe64fff5b1dc3daee32df Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 21 Jan 2014 22:12:09 -0500 Subject: [PATCH 44/63] [Fix #535] Set Pacman frontend to 'pacman' when none set --- modules/pacman/init.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index f42e0330..2b4f0a22 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -28,6 +28,7 @@ if (( $+commands[$_pacman_frontend] )); then source "${0:h}/${_pacman_frontend}.zsh" fi else + _pacman_frontend='pacman' _pacman_sudo='sudo ' fi From dbeb6d4e1aefd22d688afc3140407a5c6ca5bbb9 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 1 Feb 2014 23:37:29 -0500 Subject: [PATCH 45/63] [Fix #361] Load chruby when found --- modules/ruby/README.md | 23 +++++++++++++++++++---- modules/ruby/functions/ruby-info | 2 ++ modules/ruby/init.zsh | 7 +++++++ runcoms/zpreztorc | 7 +++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/modules/ruby/README.md b/modules/ruby/README.md index e78d7576..152e26de 100644 --- a/modules/ruby/README.md +++ b/modules/ruby/README.md @@ -8,7 +8,7 @@ Local Gem Installation ---------------------- When a Ruby version manager is not detected, local gems are installed in -*~/Library/Ruby/Gems/1.8* on Mac OS X. +*~/.gems*; otherwise, they are installed according to the manager. RVM --- @@ -23,12 +23,27 @@ may conflict with shell scripts. rbenv ----- -An alternative RVM is to use [rbenv][3], which allows for switching between multiple, -isolated Ruby installations in the home directory. +An alternative RVM is to use [rbenv][3], which allows for switching between +multiple, isolated Ruby installations in the home directory. While it is not as feature rich as RVM, it is not loaded into the shell and is not known to cause conflicts with shell scripts. +chruby +------ + +Yet another alternative is [chruby][6], which is simpler than both RVM and +rbenv. + +### Settings + +#### Auto-Switch + +To enable auto switching the Ruby version on directory change based on the +.ruby-version file, add the following line to *zpreztorc*: + + zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' + Bundler ------- @@ -87,4 +102,4 @@ Authors [3]: https://github.com/sstephenson/rbenv [4]: http://gembundler.com [5]: https://github.com/sorin-ionescu/prezto/issues - +[6]: https://github.com/postmodern/chruby diff --git a/modules/ruby/functions/ruby-info b/modules/ruby/functions/ruby-info index 7bc8ead6..b3656dd8 100644 --- a/modules/ruby/functions/ruby-info +++ b/modules/ruby/functions/ruby-info @@ -18,6 +18,8 @@ if (( $+commands[rvm-prompt] )); then version="$(rvm-prompt)" elif (( $+commands[rbenv] )); then version="$(rbenv version-name)" +elif (( $+commands[ruby] )); then + version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" fi # Format version. diff --git a/modules/ruby/init.zsh b/modules/ruby/init.zsh index 89b1345a..eb18dd37 100644 --- a/modules/ruby/init.zsh +++ b/modules/ruby/init.zsh @@ -23,6 +23,13 @@ elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then elif (( $+commands[rbenv] )); then eval "$(rbenv init - --no-rehash zsh)" +# Load package manager installed chruby into the shell session. +elif (( $+commands[chruby-exec] )); then + source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" + if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then + source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" + fi + # Prepend local gems bin directories to PATH. else path=($HOME/.gem/ruby/*/bin(N) $path) diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 9dd6c5dc..80f2a052 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -87,6 +87,13 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Auto set to 'off' on dumb terminals. zstyle ':prezto:module:prompt' theme 'sorin' +# +# Ruby +# + +# Auto switch the Ruby version on directory change. +# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' + # # Screen # From e48dac79f3c3a56d114dc863c3781d675f179e5e Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 21 May 2013 13:50:22 -0400 Subject: [PATCH 46/63] Add double slash after Bwana.app's man protocol Safari 6's unified location and search bar can no longer tell the difference between a protocol and a colon search. --- modules/osx/functions/manb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/osx/functions/manb b/modules/osx/functions/manb index aac5fb5f..66bcd6fe 100644 --- a/modules/osx/functions/manb +++ b/modules/osx/functions/manb @@ -9,7 +9,7 @@ function manb { local page if (( $# > 0 )); then for page in "$@"; do - open "man:$page" 2>/dev/null + open "man://$page" 2>/dev/null if (( $? != 0 )); then print "$0: Bwana is not installed" >&2 break From 232313e2a003b54fe746d39d684a67a77798b76b Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 21 May 2013 19:16:27 -0400 Subject: [PATCH 47/63] Remove Bwana.app support Bwana.app has been stale for years. It no longer works properly. --- modules/osx/README.md | 2 -- modules/osx/functions/{_manb_manp => _manb} | 4 ++-- modules/osx/functions/manb | 24 --------------------- 3 files changed, 2 insertions(+), 28 deletions(-) rename modules/osx/functions/{_manb_manp => _manb} (63%) delete mode 100644 modules/osx/functions/manb diff --git a/modules/osx/README.md b/modules/osx/README.md index 498ed2e5..1a63e5ee 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -15,7 +15,6 @@ Aliases Functions --------- - - `manb` opens _man_ pages in [_Bwana.app_][2]. - `manp` opens _man_ pages in _Preview.app_. - `pfd` prints the current _Finder_ directory. - `pfs` prints the current _Finder_ selection. @@ -29,7 +28,6 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.apple.com/macosx/ -[2]: http://bruji.com/bwana/ [3]: http://www.iterm2.com/ [4]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/osx/functions/_manb_manp b/modules/osx/functions/_manb similarity index 63% rename from modules/osx/functions/_manb_manp rename to modules/osx/functions/_manb index bbba2af2..b3e551f1 100644 --- a/modules/osx/functions/_manb_manp +++ b/modules/osx/functions/_manb @@ -1,8 +1,8 @@ -#compdef manb manp +#compdef manp #autoload # -# Completes manb and manp. +# Completes manp. # # Authors: # Sorin Ionescu diff --git a/modules/osx/functions/manb b/modules/osx/functions/manb deleted file mode 100644 index 66bcd6fe..00000000 --- a/modules/osx/functions/manb +++ /dev/null @@ -1,24 +0,0 @@ -# -# Opens man pages in Bwana.app. -# -# Authors: -# Sorin Ionescu -# - -function manb { - local page - if (( $# > 0 )); then - for page in "$@"; do - open "man://$page" 2>/dev/null - if (( $? != 0 )); then - print "$0: Bwana is not installed" >&2 - break - fi - done - else - print 'What manual page do you want?' >&2 - fi -} - -manb "$@" - From 00e12b7a98ceefc42090361315ddf2a72b3e2fe6 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 21 May 2013 13:46:42 -0400 Subject: [PATCH 48/63] Add capability to browse man pages in Dash.app --- modules/osx/README.md | 3 ++- .../osx/functions/{_manb => _manb_mand_manp} | 4 ++-- modules/osx/functions/mand | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) rename modules/osx/functions/{_manb => _manb_mand_manp} (63%) create mode 100644 modules/osx/functions/mand diff --git a/modules/osx/README.md b/modules/osx/README.md index 1a63e5ee..aace73c6 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -15,6 +15,7 @@ Aliases Functions --------- + - `mand` opens _man_ pages in [_Dash.app_][2]. - `manp` opens _man_ pages in _Preview.app_. - `pfd` prints the current _Finder_ directory. - `pfs` prints the current _Finder_ selection. @@ -28,6 +29,6 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.apple.com/macosx/ +[2]: http://kapeli.com/dash [3]: http://www.iterm2.com/ [4]: https://github.com/sorin-ionescu/prezto/issues - diff --git a/modules/osx/functions/_manb b/modules/osx/functions/_manb_mand_manp similarity index 63% rename from modules/osx/functions/_manb rename to modules/osx/functions/_manb_mand_manp index b3e551f1..ae5630f1 100644 --- a/modules/osx/functions/_manb +++ b/modules/osx/functions/_manb_mand_manp @@ -1,8 +1,8 @@ -#compdef manp +#compdef mand manp #autoload # -# Completes manp. +# Completes mand and manp. # # Authors: # Sorin Ionescu diff --git a/modules/osx/functions/mand b/modules/osx/functions/mand new file mode 100644 index 00000000..a22114e1 --- /dev/null +++ b/modules/osx/functions/mand @@ -0,0 +1,21 @@ +# +# Opens man pages in Dash.app. +# +# Authors: +# Sorin Ionescu +# + +function mand { + if (( $# > 0 )); then + open "dash://manpages:$1" 2>/dev/null + if (( $? != 0 )); then + print "$0: Dash is not installed" >&2 + break + fi + else + print 'What manual page do you want?' >&2 + fi +} + +mand "$@" + From b8bb51d7b52834c3ccdb074d1842febd62d65c89 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 2 Feb 2014 14:44:22 -0500 Subject: [PATCH 49/63] Cast AppleScript paths to text --- modules/osx/functions/pfd | 3 +-- modules/osx/functions/pfs | 15 ++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/modules/osx/functions/pfd b/modules/osx/functions/pfd index 3e038a68..a4d4b686 100644 --- a/modules/osx/functions/pfd +++ b/modules/osx/functions/pfd @@ -7,7 +7,6 @@ osascript 2>/dev/null < # -osascript 2>/dev/null <&1 < Date: Sun, 2 Feb 2014 20:08:21 -0500 Subject: [PATCH 50/63] Make osx functions autoloadable --- modules/osx/README.md | 5 +++-- modules/osx/functions/ql | 10 ++++++++++ modules/osx/functions/rm-osx-cruft | 11 +++++++++++ modules/osx/init.zsh | 18 ------------------ 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 modules/osx/functions/ql create mode 100644 modules/osx/functions/rm-osx-cruft diff --git a/modules/osx/README.md b/modules/osx/README.md index aace73c6..31fde4ec 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -9,8 +9,7 @@ Aliases - `cdf` changes the current working director to the current _Finder_ directory. - `pushdf` pushes the current working directory onto the directory queue and - - `ql` quick looks at files. - - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. + changes the current working director to the current _Finder_ directory. Functions --------- @@ -20,6 +19,8 @@ Functions - `pfd` prints the current _Finder_ directory. - `pfs` prints the current _Finder_ selection. - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). + - `ql` previews files in Quick Look. + - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. Authors ------- diff --git a/modules/osx/functions/ql b/modules/osx/functions/ql new file mode 100644 index 00000000..c8efa3f6 --- /dev/null +++ b/modules/osx/functions/ql @@ -0,0 +1,10 @@ +# +# Previews files in Quick Look. +# +# Authors: +# Sorin Ionescu +# + +if (( $# > 0 )); then + qlmanage -p "$@" &> /dev/null +fi diff --git a/modules/osx/functions/rm-osx-cruft b/modules/osx/functions/rm-osx-cruft new file mode 100644 index 00000000..0a91cedb --- /dev/null +++ b/modules/osx/functions/rm-osx-cruft @@ -0,0 +1,11 @@ +# +# Deletes .DS_Store and __MACOSX directories. +# +# Authors: +# Sorin Ionescu +# + +find "${@:-$PWD}" \( \ + -type f -name '.DS_Store' -o \ + -type d -name '__MACOSX' \ +\) -print0 | xargs -0 rm -rf diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index 6acbfbc7..a78f2988 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -19,21 +19,3 @@ alias cdf='cd "$(pfd)"' # Push directory to the current Finder directory. alias pushdf='pushd "$(pfd)"' - -# -# Functions -# - -# Open files in Quick Look. -function ql { - (( $# > 0 )) && qlmanage -p "$@" &> /dev/null -} - -# Delete .DS_Store and __MACOSX directories. -function rm-osx-cruft { - find "${@:-$PWD}" \( \ - -type f -name '.DS_Store' -o \ - -type d -name '__MACOSX' \ - \) -print0 | xargs -0 rm -rf -} - From 02717cb4c1fd6126d74b7df945af505d14a937cc Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 2 Feb 2014 20:08:55 -0500 Subject: [PATCH 51/63] Update osx alias descriptions --- modules/osx/init.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index a78f2988..edf6ed3d 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -14,8 +14,8 @@ fi # Aliases # -# Change directory to the current Finder directory. +# Changes directory to the current Finder directory. alias cdf='cd "$(pfd)"' -# Push directory to the current Finder directory. +# Pushes directory to the current Finder directory. alias pushdf='pushd "$(pfd)"' From 72782528aaf34ba8a281077790e3f321c42c37ee Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 2 Feb 2014 20:30:27 -0500 Subject: [PATCH 52/63] Add functions to display and delete osx download history --- modules/osx/README.md | 2 ++ modules/osx/functions/ls-osx-download-history | 13 +++++++++++++ modules/osx/functions/rm-osx-download-history | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 modules/osx/functions/ls-osx-download-history create mode 100644 modules/osx/functions/rm-osx-download-history diff --git a/modules/osx/README.md b/modules/osx/README.md index 31fde4ec..ee74ce99 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -21,6 +21,8 @@ Functions - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). - `ql` previews files in Quick Look. - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. + - `ls-osx-download-history` displays the Mac OS X download history. + - `rm-osx-download-history` deletes the Mac OS X download history. Authors ------- diff --git a/modules/osx/functions/ls-osx-download-history b/modules/osx/functions/ls-osx-download-history new file mode 100644 index 00000000..5727c1b3 --- /dev/null +++ b/modules/osx/functions/ls-osx-download-history @@ -0,0 +1,13 @@ +# +# Displays the Mac OS X download history. +# +# Authors: +# Sorin Ionescu +# + +local db +for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do + if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then + sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent' + fi +done diff --git a/modules/osx/functions/rm-osx-download-history b/modules/osx/functions/rm-osx-download-history new file mode 100644 index 00000000..38377098 --- /dev/null +++ b/modules/osx/functions/rm-osx-download-history @@ -0,0 +1,13 @@ +# +# Deletes the Mac OS X download history. +# +# Authors: +# Sorin Ionescu +# + +local db +for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do + if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then + sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM' + fi +done From c74cf4b5e0c42048be81c1c6ccdd2471e81abbef Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 16 Feb 2014 18:00:47 -0500 Subject: [PATCH 53/63] Prefix rarely used osx functions --- modules/osx/README.md | 6 +++--- .../{ls-osx-download-history => osx-ls-download-history} | 0 modules/osx/functions/{rm-osx-cruft => osx-rm-dir-metadata} | 0 .../{rm-osx-download-history => osx-rm-download-history} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename modules/osx/functions/{ls-osx-download-history => osx-ls-download-history} (100%) rename modules/osx/functions/{rm-osx-cruft => osx-rm-dir-metadata} (100%) rename modules/osx/functions/{rm-osx-download-history => osx-rm-download-history} (100%) diff --git a/modules/osx/README.md b/modules/osx/README.md index ee74ce99..d8eff0ff 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -20,9 +20,9 @@ Functions - `pfs` prints the current _Finder_ selection. - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). - `ql` previews files in Quick Look. - - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. - - `ls-osx-download-history` displays the Mac OS X download history. - - `rm-osx-download-history` deletes the Mac OS X download history. + - `osx-rm-dir-metadata` deletes .DS\_Store, \_\_MACOSX cruft. + - `osx-ls-download-history` displays the Mac OS X download history. + - `osx-rm-download-history` deletes the Mac OS X download history. Authors ------- diff --git a/modules/osx/functions/ls-osx-download-history b/modules/osx/functions/osx-ls-download-history similarity index 100% rename from modules/osx/functions/ls-osx-download-history rename to modules/osx/functions/osx-ls-download-history diff --git a/modules/osx/functions/rm-osx-cruft b/modules/osx/functions/osx-rm-dir-metadata similarity index 100% rename from modules/osx/functions/rm-osx-cruft rename to modules/osx/functions/osx-rm-dir-metadata diff --git a/modules/osx/functions/rm-osx-download-history b/modules/osx/functions/osx-rm-download-history similarity index 100% rename from modules/osx/functions/rm-osx-download-history rename to modules/osx/functions/osx-rm-download-history From 81895777728a5651fa319662fc986665a2c067b0 Mon Sep 17 00:00:00 2001 From: Laurent Goussard Date: Sun, 16 Feb 2014 18:29:01 -0500 Subject: [PATCH 54/63] Disable glob for bower Signed-off-by: Sorin Ionescu --- modules/utility/README.md | 1 + modules/utility/init.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/utility/README.md b/modules/utility/README.md index ebcc43c5..6871be54 100644 --- a/modules/utility/README.md +++ b/modules/utility/README.md @@ -50,6 +50,7 @@ Aliases ### Disabled File Globbing + - `bower` - `fc` - `find` - `ftp` diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 91c78090..2c34a74d 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -34,6 +34,7 @@ alias mysql='nocorrect mysql' alias rm='nocorrect rm' # Disable globbing. +alias bower='noglob bower' alias fc='noglob fc' alias find='noglob find' alias ftp='noglob ftp' From e5a0e33f1c6ee95159f9c765ef5dae842b07d389 Mon Sep 17 00:00:00 2001 From: Gaelan D'costa Date: Mon, 17 Feb 2014 17:57:34 -0500 Subject: [PATCH 55/63] [Fix #541] Do not auto-load screen/tmux inside of Emacs/Vim When Emacs and Vim are launched from outside of an interactive shell, $TMUX and $STY are not set; check for Emacs and Vim environment variables instead. Signed-off-by: Sorin Ionescu --- modules/screen/init.zsh | 2 +- modules/tmux/init.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index f10efb73..0d511bf4 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -15,7 +15,7 @@ fi # Auto Start # -if [[ -z "$STY" ]] && ( \ +if [[ -z "$STY" && ( -n "$INSIDE_EMACS" || -n "$EMACS" || -n "$VIM" ) ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) \ ); then diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index a59b259a..b048d2eb 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -16,7 +16,7 @@ fi # Auto Start # -if [[ -z "$TMUX" ]] && ( \ +if [[ -z "$TMUX" && ( -n "$INSIDE_EMACS" || -n "$EMACS" || -n "$VIM" ) ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then From 415e4bff3d7295f86758ce24c898ff78b909736a Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 17 Feb 2014 23:09:11 -0500 Subject: [PATCH 56/63] Fix a test operator bug introduced in e5a0e33 --- modules/screen/init.zsh | 2 +- modules/tmux/init.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index 0d511bf4..a9a09682 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -15,7 +15,7 @@ fi # Auto Start # -if [[ -z "$STY" && ( -n "$INSIDE_EMACS" || -n "$EMACS" || -n "$VIM" ) ]] && ( \ +if [[ -z "$STY" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) \ ); then diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index b048d2eb..aba686b1 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -16,7 +16,7 @@ fi # Auto Start # -if [[ -z "$TMUX" && ( -n "$INSIDE_EMACS" || -n "$EMACS" || -n "$VIM" ) ]] && ( \ +if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then From 240eecaddfad00e6d05c5d534d785432d353afea Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 17 Feb 2014 23:27:03 -0500 Subject: [PATCH 57/63] [Fix #551] Rename tmux auto-start session --- modules/tmux/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index aba686b1..f7f4c7ed 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -20,7 +20,7 @@ if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then - tmux_session='#Prezto' + tmux_session='prezto' if ! tmux has-session -t "$tmux_session" 2> /dev/null; then # Ensure that tmux server is started. From 7722dd4400dd7cea56433253eb6e6967a02c486f Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 17 Feb 2014 23:39:08 -0500 Subject: [PATCH 58/63] Inform the user to load ruby as late as possible when using RVM --- modules/ruby/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/ruby/README.md b/modules/ruby/README.md index 152e26de..1c955f5e 100644 --- a/modules/ruby/README.md +++ b/modules/ruby/README.md @@ -20,6 +20,9 @@ home directory. Since RVM is loaded into the shell and is known to override shell commands, it may conflict with shell scripts. +Load this module as late as possible when using RVM since RVM will complain if +it is not first in `$PATH`. + rbenv ----- From 10cf7018645fd9c09a0aa03c4ebac5ae6222c77e Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 26 Feb 2014 17:19:19 -0500 Subject: [PATCH 59/63] Simplify multiplexer auto-start tests --- modules/screen/init.zsh | 2 +- modules/tmux/init.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index a9a09682..7a5cee3d 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -15,7 +15,7 @@ fi # Auto Start # -if [[ -z "$STY" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ +if [[ -z "$STY" && -z "$EMACS" && -z "$VIM" ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) \ ); then diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index f7f4c7ed..bee24e4c 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -16,7 +16,7 @@ fi # Auto Start # -if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ +if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then From 478653fab230bff1e3ff39da5693f44de79c3c5b Mon Sep 17 00:00:00 2001 From: Xavier Cambar Date: Fri, 21 Feb 2014 20:13:21 +0100 Subject: [PATCH 60/63] [Fix #543] Do not set tmux destroy-unattached Signed-off-by: Sorin Ionescu --- modules/tmux/README.md | 16 ++++++++++------ modules/tmux/init.zsh | 26 +++++++++----------------- runcoms/zpreztorc | 1 - 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/modules/tmux/README.md b/modules/tmux/README.md index 68ba9d06..0e2f652f 100644 --- a/modules/tmux/README.md +++ b/modules/tmux/README.md @@ -20,12 +20,15 @@ following line to *zpreztorc*: zstyle ':prezto:module:tmux:auto-start' remote 'yes' -In both cases, it will create a background session named _#Prezto_ and attach -every new shell to it. +In both cases, it will create a background session named _prezto_ if the tmux +server is not started. -To avoid keeping open sessions, this module sets `destroy-unattached off` on -the background session and `destroy-unattached on` on every other session -(global setting). +With `auto-start` enabled, you may want to control how multiple sessions are +managed. The `destroy-unattached` option of tmux controls if the unattached +sessions must be kept alive, making sessions available for later use, configured +in *tmux.conf*: + + set-option -g destroy-unattached [on | off] Aliases ------- @@ -41,7 +44,7 @@ connected** to be displayed, which can be fixed by installing [reattach-to-user-namespace][3], available in [Homebrew][4], and adding the following to *tmux.conf*: - set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" + set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" Furthermore, tmux is known to cause **kernel panics** on Mac OS X. A discussion about this and Prezto has already been [opened][2]. @@ -54,6 +57,7 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) - [Colin Hebert](https://github.com/ColinHebert) - [Georges Discry](https://github.com/gdiscry) + - [Xavier Cambar](https://github.com/xcambar) [1]: http://tmux.sourceforge.net [2]: https://github.com/sorin-ionescu/prezto/issues/62 diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index bee24e4c..c6c3626f 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -5,6 +5,7 @@ # Sorin Ionescu # Colin Hebert # Georges Discry +# Xavier Cambar # # Return if requirements are not found. @@ -22,25 +23,16 @@ if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ ); then tmux_session='prezto' - if ! tmux has-session -t "$tmux_session" 2> /dev/null; then - # Ensure that tmux server is started. - tmux start-server - - # Disable the destruction of unattached sessions globally. - tmux set-option -g destroy-unattached off &> /dev/null - - # Create a new session. - tmux new-session -d -s "$tmux_session" - - # Disable the destruction of the new, unattached session. - tmux set-option -t "$tmux_session" destroy-unattached off &> /dev/null - - # Enable the destruction of unattached sessions globally to prevent - # an abundance of open, detached sessions. - tmux set-option -g destroy-unattached on &> /dev/null + # Create a first 'prezto' session if tmux is starting. + if ! tmux has-session 2> /dev/null; then + tmux \ + start-server \; \ + new-session -d -s "$tmux_session" \; \ + set-option -t "$tmux_session" destroy-unattached off &> /dev/null fi - exec tmux new-session -t "$tmux_session" + # Attach to the 'prezto' session or to the last session used. + exec tmux attach-session fi # diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 80f2a052..a54fdb02 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -152,4 +152,3 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto start a session when Zsh is launched in a SSH connection. # zstyle ':prezto:module:tmux:auto-start' remote 'yes' - From fedad8e9cfbd00a03170bd80cc82c1ba85f9ba25 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Thu, 6 Mar 2014 20:39:50 +0100 Subject: [PATCH 61/63] Fix git-info added/deleted count formatting typo Signed-off-by: Sorin Ionescu --- modules/git/functions/git-info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index 1c163962..bc627240 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -348,13 +348,13 @@ function git-info { # Format added. if (( added > 0 )); then zstyle -s ':prezto:module:git:info:added' format 'added_format' - zformat -f added_formatted "$added_format" "a:$added_format" + zformat -f added_formatted "$added_format" "a:$added" fi # Format deleted. if (( deleted > 0 )); then zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format' - zformat -f deleted_formatted "$deleted_format" "d:$deleted_format" + zformat -f deleted_formatted "$deleted_format" "d:$deleted" fi # Format modified. From ff0dfa424d7f2b32379aad37e1c2ead4457866d8 Mon Sep 17 00:00:00 2001 From: Xavier Cambar Date: Wed, 12 Mar 2014 16:59:00 +0100 Subject: [PATCH 62/63] Create a default tmux session only when none defined in tmux.conf Signed-off-by: Sorin Ionescu --- modules/tmux/init.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index c6c3626f..29b547f3 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -21,12 +21,12 @@ if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then - tmux_session='prezto' + tmux start-server - # Create a first 'prezto' session if tmux is starting. + # Create a 'prezto' session if no session has been defined in tmux.conf. if ! tmux has-session 2> /dev/null; then + tmux_session='prezto' tmux \ - start-server \; \ new-session -d -s "$tmux_session" \; \ set-option -t "$tmux_session" destroy-unattached off &> /dev/null fi From bf9dbfd5b95c44b14a8a6af8ecf965ecea50fb29 Mon Sep 17 00:00:00 2001 From: Arthur Noel Date: Mon, 17 Mar 2014 17:31:21 +0000 Subject: [PATCH 63/63] Support $PYTHONUSERBASE per PEP 370 Signed-off-by: Sorin Ionescu --- modules/python/init.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/python/init.zsh b/modules/python/init.zsh index fa9175e5..5715b024 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -16,9 +16,12 @@ elif (( $+commands[pyenv] )); then eval "$(pyenv init -)" # Prepend PEP 370 per user site packages directory, which defaults to -# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. +# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. The +# path can be overridden using PYTHONUSERBASE. else - if [[ "$OSTYPE" == darwin* ]]; then + if [[ -n "$PYTHONUSERBASE" ]]; then + path=($PYTHONUSERBASE/bin $path) + elif [[ "$OSTYPE" == darwin* ]]; then path=($HOME/Library/Python/*/bin(N) $path) else # This is subject to change.