Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  Simplify multiplexer auto-start tests
  Inform the user to load ruby as late as possible when using RVM
  [Fix sorin-ionescu#551] Rename tmux auto-start session
  Fix a test operator bug introduced in e5a0e33
  [Fix sorin-ionescu#541] Do not auto-load screen/tmux inside of Emacs/Vim
  Disable glob for bower
  Prefix rarely used osx functions
  Add functions to display and delete osx download history
  Update osx alias descriptions
  Make osx functions autoloadable
  Cast AppleScript paths to text
  Add capability to browse man pages in Dash.app
  Remove Bwana.app support
  Add double slash after Bwana.app's man protocol
  [Fix sorin-ionescu#361] Load chruby when found
  [Fix sorin-ionescu#535] Set Pacman frontend to 'pacman' when none set
  • Loading branch information
duellj committed Mar 3, 2014
2 parents 8a8f437 + 10cf701 commit 3bb76e6
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 69 deletions.
12 changes: 7 additions & 5 deletions modules/osx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand All @@ -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

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#compdef manb manp
#compdef mand manp
#autoload

#
# Completes manb and manp.
# Completes mand and manp.
#
# Authors:
# Sorin Ionescu <[email protected]>
Expand Down
24 changes: 0 additions & 24 deletions modules/osx/functions/manb

This file was deleted.

21 changes: 21 additions & 0 deletions modules/osx/functions/mand
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Opens man pages in Dash.app.
#
# Authors:
# Sorin Ionescu <[email protected]>
#

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 "$@"

13 changes: 13 additions & 0 deletions modules/osx/functions/osx-ls-download-history
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Displays the Mac OS X download history.
#
# Authors:
# Sorin Ionescu <[email protected]>
#

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
11 changes: 11 additions & 0 deletions modules/osx/functions/osx-rm-dir-metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Deletes .DS_Store and __MACOSX directories.
#
# Authors:
# Sorin Ionescu <[email protected]>
#

find "${@:-$PWD}" \( \
-type f -name '.DS_Store' -o \
-type d -name '__MACOSX' \
\) -print0 | xargs -0 rm -rf
13 changes: 13 additions & 0 deletions modules/osx/functions/osx-rm-download-history
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Deletes the Mac OS X download history.
#
# Authors:
# Sorin Ionescu <[email protected]>
#

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
3 changes: 1 addition & 2 deletions modules/osx/functions/pfd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

osascript 2>/dev/null <<EOF
tell application "Finder"
return POSIX path of (target of window 1 as alias)
return POSIX path of (target of first window as text)
end tell
EOF

15 changes: 6 additions & 9 deletions modules/osx/functions/pfs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
# Sorin Ionescu <[email protected]>
#

osascript 2>/dev/null <<EOF
set output to ""
osascript 2>&1 <<EOF
tell application "Finder" to set the_selection to selection
set item_count to count the_selection
repeat with item_index from 1 to count the_selection
if item_index is less than item_count then set the_delimiter to "\n"
if item_index is item_count then set the_delimiter to ""
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
end repeat
if the_selection is not {}
repeat with an_item in the_selection
log POSIX path of (an_item as text)
end repeat
end if
EOF

10 changes: 10 additions & 0 deletions modules/osx/functions/ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Previews files in Quick Look.
#
# Authors:
# Sorin Ionescu <[email protected]>
#

if (( $# > 0 )); then
qlmanage -p "$@" &> /dev/null
fi
22 changes: 2 additions & 20 deletions modules/osx/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

1 change: 1 addition & 0 deletions modules/pacman/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (( $+commands[$_pacman_frontend] )); then
source "${0:h}/${_pacman_frontend}.zsh"
fi
else
_pacman_frontend='pacman'
_pacman_sudo='sudo '
fi

Expand Down
26 changes: 22 additions & 4 deletions modules/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand All @@ -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
-------

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions modules/ruby/functions/ruby-info
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions modules/ruby/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/screen/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/tmux/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions modules/utility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Aliases

### Disabled File Globbing

- `bower`
- `fc`
- `find`
- `ftp`
Expand Down
1 change: 1 addition & 0 deletions modules/utility/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions runcoms/zpreztorc
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down

0 comments on commit 3bb76e6

Please sign in to comment.