1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-07-01 15:09:25 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
36e24eeb08 git-hub-shorten-url: Slug support 2014-02-20 13:03:18 -06:00
22 changed files with 95 additions and 143 deletions

View File

@ -99,13 +99,14 @@ zstyle -e ':completion:*:hosts' hosts 'reply=(
)'
# Don't complete uninteresting users...
zstyle ':completion:*:*:*:users' ignored-patterns nobody nobody4 noaccess '_*' \
$([[ "$OSTYPE" = SunOS ]] && uid_min=100 || uid_min=500
IFS=:
while read -r user pass uid remainder; do
[[ "$user" != (\#*|root) ]] && ((uid < uid_min)) && echo $user
done </etc/passwd
)
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
mailman mailnull mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*'
# ... unless we really want to.
zstyle '*' single-ignored show

View File

@ -5,8 +5,11 @@
# Completes git-hub-shorten-url.
#
# Authors:
# Joel Kuzmarski <leoj3n@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
_arguments '1:url:' && return 0
_arguments \
'1:url:' \
'2:slug:' && return 0

View File

@ -2,21 +2,29 @@
# Shortens GitHub URLs.
#
# Authors:
# Joel Kuzmarski <leoj3n@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local url="$1"
if [[ "$url" == '-' ]]; then
read url <&0
fi
if [[ -z "$url" ]]; then
print "usage: $0 [ url | - ]" >&2
print "usage: $0 [ url | - ] [slug]" >&2
return 1
elif [[ "$url" == '-' ]]; then
read url <&0
elif [[ "$url" != *github.com* ]]; then
url="https://github.com/$url"
fi
if (( $+commands[curl] )); then
curl -s -i 'http://git.io' -F "url=$url" | grep 'Location:' | sed 's/Location: //'
local result="$(curl -s -i 'http://git.io' -F "url=$url" -F "code=$2")"
if [[ $result == *Unprocessable* ]]; then
print "$0: the slug '$2' is already taken!" >&2
else
print $result | grep 'Location:' | sed 's/Location: //'
fi
else
print "$0: command not found: curl" >&2
fi

View File

@ -9,20 +9,17 @@ Aliases
- `cdf` changes the current working director to the current _Finder_
directory.
- `pushdf` pushes the current working directory onto the directory queue and
changes the current working director to the current _Finder_ directory.
- `ql` quick looks at files.
- `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft.
Functions
---------
- `mand` opens _man_ pages in [_Dash.app_][2].
- `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.
- `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
-------
@ -32,6 +29,7 @@ Authors
- [Sorin Ionescu](https://github.com/sorin-ionescu)
[1]: http://www.apple.com/macosx/
[2]: http://kapeli.com/dash
[2]: http://bruji.com/bwana/
[3]: http://www.iterm2.com/
[4]: https://github.com/sorin-ionescu/prezto/issues

View File

@ -1,8 +1,8 @@
#compdef mand manp
#compdef manb manp
#autoload
#
# Completes mand and manp.
# Completes manb and manp.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>

View File

@ -0,0 +1,24 @@
#
# Opens man pages in Bwana.app.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
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 "$@"

View File

@ -1,21 +0,0 @@
#
# Opens man pages in Dash.app.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
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 "$@"

View File

@ -1,13 +0,0 @@
#
# Displays the Mac OS X download history.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
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

View File

@ -1,11 +0,0 @@
#
# Deletes .DS_Store and __MACOSX directories.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
find "${@:-$PWD}" \( \
-type f -name '.DS_Store' -o \
-type d -name '__MACOSX' \
\) -print0 | xargs -0 rm -rf

View File

@ -1,13 +0,0 @@
#
# Deletes the Mac OS X download history.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
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

View File

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

View File

@ -5,11 +5,14 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
osascript 2>&1 <<EOF
osascript 2>/dev/null <<EOF
set output to ""
tell application "Finder" to set the_selection to selection
if the_selection is not {}
repeat with an_item in the_selection
log POSIX path of (an_item as text)
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
end if
EOF

View File

@ -1,10 +0,0 @@
#
# Previews files in Quick Look.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if (( $# > 0 )); then
qlmanage -p "$@" &> /dev/null
fi

View File

@ -14,8 +14,26 @@ fi
# Aliases
#
# Changes directory to the current Finder directory.
# Change directory to the current Finder directory.
alias cdf='cd "$(pfd)"'
# Pushes directory to the current Finder directory.
# 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
}

View File

@ -8,7 +8,7 @@ Local Gem Installation
----------------------
When a Ruby version manager is not detected, local gems are installed in
*~/.gems*; otherwise, they are installed according to the manager.
*~/Library/Ruby/Gems/1.8* on Mac OS X.
RVM
---
@ -20,33 +20,15 @@ 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
-------
@ -105,4 +87,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

View File

@ -18,8 +18,6 @@ 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.

View File

@ -23,13 +23,6 @@ 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)

View File

@ -15,7 +15,7 @@ fi
# Auto Start
#
if [[ -z "$STY" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \
if [[ -z "$STY" ]] && ( \
( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) ||
( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) \
); then

View File

@ -16,11 +16,11 @@ fi
# Auto Start
#
if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \
if [[ -z "$TMUX" ]] && ( \
( [[ -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.

View File

@ -50,7 +50,6 @@ Aliases
### Disabled File Globbing
- `bower`
- `fc`
- `find`
- `ftp`

View File

@ -34,7 +34,6 @@ 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'

View File

@ -87,13 +87,6 @@ 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
#