diff --git a/modules/osx/README.md b/modules/osx/README.md index 498ed2e506..d8eff0ff36 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -9,17 +9,20 @@ 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 --------- - - `manb` opens _man_ pages in [_Bwana.app_][2]. + - `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. - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). + - `ql` previews files in Quick Look. + - `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 ------- @@ -29,7 +32,6 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.apple.com/macosx/ -[2]: http://bruji.com/bwana/ +[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_manp b/modules/osx/functions/_manb_mand_manp similarity index 63% rename from modules/osx/functions/_manb_manp rename to modules/osx/functions/_manb_mand_manp index bbba2af2f1..ae5630f112 100644 --- a/modules/osx/functions/_manb_manp +++ b/modules/osx/functions/_manb_mand_manp @@ -1,8 +1,8 @@ -#compdef manb manp +#compdef mand manp #autoload # -# Completes manb and manp. +# Completes mand and manp. # # Authors: # Sorin Ionescu diff --git a/modules/osx/functions/manb b/modules/osx/functions/manb deleted file mode 100644 index aac5fb5f8e..0000000000 --- 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 "$@" - diff --git a/modules/osx/functions/mand b/modules/osx/functions/mand new file mode 100644 index 0000000000..a22114e1a0 --- /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 "$@" + diff --git a/modules/osx/functions/osx-ls-download-history b/modules/osx/functions/osx-ls-download-history new file mode 100644 index 0000000000..5727c1b33e --- /dev/null +++ b/modules/osx/functions/osx-ls-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/osx-rm-dir-metadata b/modules/osx/functions/osx-rm-dir-metadata new file mode 100644 index 0000000000..0a91cedb66 --- /dev/null +++ b/modules/osx/functions/osx-rm-dir-metadata @@ -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/functions/osx-rm-download-history b/modules/osx/functions/osx-rm-download-history new file mode 100644 index 0000000000..3837709871 --- /dev/null +++ b/modules/osx/functions/osx-rm-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 diff --git a/modules/osx/functions/pfd b/modules/osx/functions/pfd index 3e038a68b5..a4d4b686bb 100644 --- a/modules/osx/functions/pfd +++ b/modules/osx/functions/pfd @@ -7,7 +7,6 @@ osascript 2>/dev/null < # -osascript 2>/dev/null <&1 < +# + +if (( $# > 0 )); then + qlmanage -p "$@" &> /dev/null +fi diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index 6acbfbc762..edf6ed3d5f 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -14,26 +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)"' - -# -# 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 -} - diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index f42e0330a2..2b4f0a22e4 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 diff --git a/modules/ruby/README.md b/modules/ruby/README.md index e78d7576d6..1c955f5e63 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 --- @@ -20,15 +20,33 @@ 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 ----- -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 +105,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 7bc8ead64c..b3656dd85e 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 89b1345a08..eb18dd3715 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/modules/screen/init.zsh b/modules/screen/init.zsh index f10efb735d..7a5cee3ded 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -15,7 +15,7 @@ fi # Auto Start # -if [[ -z "$STY" ]] && ( \ +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 a59b259a2d..bee24e4ca5 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -16,11 +16,11 @@ fi # Auto Start # -if [[ -z "$TMUX" ]] && ( \ +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_session='prezto' if ! tmux has-session -t "$tmux_session" 2> /dev/null; then # Ensure that tmux server is started. diff --git a/modules/utility/README.md b/modules/utility/README.md index ebcc43c54c..6871be5457 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 91c7809021..2c34a74d85 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' diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index b764a1947b..3ed1153158 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -98,6 +98,13 @@ zstyle ':prezto:module:history-substring-search:color' found 'fg=yellow,standout # 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 #