commit
06bd72f842
24 changed files with 633 additions and 153 deletions
@ -0,0 +1,99 @@ |
|||||||
|
# |
||||||
|
# INSTRUCTIONS |
||||||
|
# |
||||||
|
# With either a manual or brew installed chruby things should just work. |
||||||
|
# |
||||||
|
# If you'd prefer to specify an explicit path to load chruby from |
||||||
|
# you can set variables like so: |
||||||
|
# |
||||||
|
# zstyle :omz:plugins:chruby path /local/path/to/chruby.sh |
||||||
|
# zstyle :omz:plugins:chruby auto /local/path/to/auto.sh |
||||||
|
# |
||||||
|
# TODO |
||||||
|
# - autodetermine correct source path on non OS X systems |
||||||
|
# - completion if ruby-install exists |
||||||
|
|
||||||
|
# rvm and rbenv plugins also provide this alias |
||||||
|
alias rubies='chruby' |
||||||
|
|
||||||
|
local _chruby_path |
||||||
|
local _chruby_auto |
||||||
|
|
||||||
|
_homebrew-installed() { |
||||||
|
whence brew &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
_chruby-from-homebrew-installed() { |
||||||
|
brew --prefix chruby &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
_ruby-build_installed() { |
||||||
|
whence ruby-build &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
_ruby-install-installed() { |
||||||
|
whence ruby-install &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
# Simple definition completer for ruby-build |
||||||
|
if _ruby-build_installed; then |
||||||
|
_ruby-build() { compadd $(ruby-build --definitions) } |
||||||
|
compdef _ruby-build ruby-build |
||||||
|
fi |
||||||
|
|
||||||
|
_source_from_omz_settings() { |
||||||
|
zstyle -s :omz:plugins:chruby path _chruby_path |
||||||
|
zstyle -s :omz:plugins:chruby auto _chruby_auto |
||||||
|
|
||||||
|
if _chruby_path && [[ -r _chruby_path ]]; then |
||||||
|
source ${_chruby_path} |
||||||
|
fi |
||||||
|
|
||||||
|
if _chruby_auto && [[ -r _chruby_auto ]]; then |
||||||
|
source ${_chruby_auto} |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
_chruby_dirs() { |
||||||
|
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies) |
||||||
|
for dir in chrubydirs; do |
||||||
|
if [[ -d $dir ]]; then |
||||||
|
RUBIES+=$dir |
||||||
|
fi |
||||||
|
done |
||||||
|
} |
||||||
|
|
||||||
|
if _homebrew-installed && _chruby-from-homebrew-installed ; then |
||||||
|
source $(brew --prefix chruby)/share/chruby/chruby.sh |
||||||
|
source $(brew --prefix chruby)/share/chruby/auto.sh |
||||||
|
_chruby_dirs |
||||||
|
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then |
||||||
|
source /usr/local/share/chruby/chruby.sh |
||||||
|
source /usr/local/share/chruby/auto.sh |
||||||
|
_chruby_dirs |
||||||
|
else |
||||||
|
_source_from_omz_settings |
||||||
|
_chruby_dirs |
||||||
|
fi |
||||||
|
|
||||||
|
function ensure_chruby() { |
||||||
|
$(whence chruby) |
||||||
|
} |
||||||
|
|
||||||
|
function current_ruby() { |
||||||
|
local _ruby |
||||||
|
_ruby="$(chruby |grep \* |tr -d '* ')" |
||||||
|
if [[ $(chruby |grep -c \*) -eq 1 ]]; then |
||||||
|
echo ${_ruby} |
||||||
|
else |
||||||
|
echo "system" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
function chruby_prompt_info() { |
||||||
|
echo "$(current_ruby)" |
||||||
|
} |
||||||
|
|
||||||
|
# complete on installed rubies |
||||||
|
_chruby() { compadd $(chruby | tr -d '* ') } |
||||||
|
compdef _chruby chruby |
||||||
@ -0,0 +1,78 @@ |
|||||||
|
# Usage: |
||||||
|
# Just add pip to your installed plugins. |
||||||
|
|
||||||
|
# If you would like to change the cheeseshops used for autocomplete set |
||||||
|
# ZSH_PIP_INDEXES in your zshrc. If one of your indexes are bogus you won't get |
||||||
|
# any kind of error message, pip will just not autocomplete from them. Double |
||||||
|
# check! |
||||||
|
# |
||||||
|
# If you would like to clear your cache, go ahead and do a |
||||||
|
# "zsh-pip-clear-cache". |
||||||
|
|
||||||
|
ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache |
||||||
|
ZSH_PIP_INDEXES=(https://pypi.python.org/simple/) |
||||||
|
|
||||||
|
zsh-pip-clear-cache() { |
||||||
|
rm $ZSH_PIP_CACHE_FILE |
||||||
|
unset piplist |
||||||
|
} |
||||||
|
|
||||||
|
zsh-pip-clean-packages() { |
||||||
|
sed -n '/<a href/ s/.*>\([^<]\{1,\}\).*/\1/p' |
||||||
|
} |
||||||
|
|
||||||
|
zsh-pip-cache-packages() { |
||||||
|
if [[ ! -d ${ZSH_PIP_CACHE_FILE:h} ]]; then |
||||||
|
mkdir -p ${ZSH_PIP_CACHE_FILE:h} |
||||||
|
fi |
||||||
|
|
||||||
|
if [[ ! -f $ZSH_PIP_CACHE_FILE ]]; then |
||||||
|
echo -n "(...caching package index...)" |
||||||
|
tmp_cache=/tmp/zsh_tmp_cache |
||||||
|
for index in $ZSH_PIP_INDEXES ; do |
||||||
|
# well... I've already got two problems |
||||||
|
curl $index 2>/dev/null | \ |
||||||
|
zsh-pip-clean-packages \ |
||||||
|
>> $tmp_cache |
||||||
|
done |
||||||
|
sort $tmp_cache | uniq | tr '\n' ' ' > $ZSH_PIP_CACHE_FILE |
||||||
|
rm $tmp_cache |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
# A test function that validates the regex against known forms of the simple |
||||||
|
# index. If you modify the regex to make it work for you, you should add a test |
||||||
|
# case in here and make sure that your changes don't break things for someone |
||||||
|
# else. |
||||||
|
zsh-pip-test-clean-packages() { |
||||||
|
local expected |
||||||
|
local actual |
||||||
|
expected="0x10c-asm |
||||||
|
1009558_nester" |
||||||
|
|
||||||
|
actual=$(echo -n "<html><head><title>Simple Index</title><meta name=\"api-version\" value=\"2\" /></head><body> |
||||||
|
<a href='0x10c-asm'>0x10c-asm</a><br/> |
||||||
|
<a href='1009558_nester'>1009558_nester</a><br/> |
||||||
|
</body></html>" | zsh-pip-clean-packages) |
||||||
|
|
||||||
|
if [[ $actual != $expected ]] ; then |
||||||
|
echo -e "python's simple index is broken:\n$actual\n !=\n$expected" |
||||||
|
else |
||||||
|
echo "python's simple index is fine" |
||||||
|
fi |
||||||
|
|
||||||
|
actual=$(echo -n '<html> |
||||||
|
<head> |
||||||
|
<title>Simple Package Index</title> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<a href="0x10c-asm">0x10c-asm</a><br/> |
||||||
|
<a href="1009558_nester">1009558_nester</a><br/> |
||||||
|
</body></html>' | zsh-pip-clean-packages) |
||||||
|
|
||||||
|
if [[ $actual != $expected ]] ; then |
||||||
|
echo -e "the djangopypi2 index is broken:\n$actual\n !=\n$expected" |
||||||
|
else |
||||||
|
echo "the djangopypi2 index is fine" |
||||||
|
fi |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
_homebrew-installed() { |
||||||
|
type brew &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
_pyenv-from-homebrew-installed() { |
||||||
|
brew --prefix pyenv &> /dev/null |
||||||
|
} |
||||||
|
|
||||||
|
FOUND_PYENV=0 |
||||||
|
pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv") |
||||||
|
if _homebrew-installed && _pyenv-from-homebrew-installed ; then |
||||||
|
pyenvdirs=($(brew --prefix pyenv) "${pyenvdirs[@]}") |
||||||
|
fi |
||||||
|
|
||||||
|
for pyenvdir in "${pyenvdirs[@]}" ; do |
||||||
|
if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then |
||||||
|
FOUND_PYENV=1 |
||||||
|
export PYENV_ROOT=$pyenvdir |
||||||
|
export PATH=${pyenvdir}/bin:$PATH |
||||||
|
eval "$(pyenv init --no-rehash - zsh)" |
||||||
|
|
||||||
|
function pyenv_prompt_info() { |
||||||
|
echo "$(pyenv version-name)" |
||||||
|
} |
||||||
|
fi |
||||||
|
done |
||||||
|
unset pyenvdir |
||||||
|
|
||||||
|
if [ $FOUND_PYENV -eq 0 ] ; then |
||||||
|
function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" } |
||||||
|
fi |
||||||
@ -1,32 +1,4 @@ |
|||||||
# Rails 3 aliases, backwards-compatible with Rails 2. |
echo "It looks like you have been using the 'rails3' plugin," |
||||||
|
echo "which has been deprecated in favor of a newly consolidated 'rails' plugin." |
||||||
function _rails_command () { |
echo "You will want to modify your ~/.zshrc configuration to begin using it." |
||||||
if [ -e "script/server" ]; then |
echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240" |
||||||
ruby script/$@ |
|
||||||
else |
|
||||||
if [ -e "bin/rails" ]; then |
|
||||||
bin/rails $@ |
|
||||||
else |
|
||||||
rails $@ |
|
||||||
fi |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
alias rc='_rails_command console' |
|
||||||
alias rd='_rails_command destroy' |
|
||||||
alias rdb='_rails_command dbconsole' |
|
||||||
alias rdbm='rake db:migrate db:test:clone' |
|
||||||
alias rg='_rails_command generate' |
|
||||||
alias rgm='_rails_command generate migration' |
|
||||||
alias rp='_rails_command plugin' |
|
||||||
alias ru='_rails_command runner' |
|
||||||
alias rs='_rails_command server' |
|
||||||
alias rsd='_rails_command server --debugger' |
|
||||||
alias devlog='tail -f log/development.log' |
|
||||||
alias testlog='tail -f log/test.log' |
|
||||||
alias prodlog='tail -f log/production.log' |
|
||||||
alias rdm='rake db:migrate' |
|
||||||
alias rdr='rake db:rollback' |
|
||||||
alias -g RET='RAILS_ENV=test' |
|
||||||
alias -g REP='RAILS_ENV=production' |
|
||||||
alias -g RED='RAILS_ENV=development' |
|
||||||
|
|||||||
@ -1,32 +1,4 @@ |
|||||||
# Rails 4 aliases |
echo "It looks like you have been using the 'rails4' plugin," |
||||||
|
echo "which has been deprecated in favor of a newly consolidated 'rails' plugin." |
||||||
function _rails_command () { |
echo "You will want to modify your ~/.zshrc configuration to begin using it." |
||||||
if [ -e "script/server" ]; then |
echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240" |
||||||
ruby script/$@ |
|
||||||
elif [ -e "script/rails" ]; then |
|
||||||
ruby script/rails $@ |
|
||||||
else |
|
||||||
ruby bin/rails $@ |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
alias rc='_rails_command console' |
|
||||||
alias rd='_rails_command destroy' |
|
||||||
alias rdb='_rails_command dbconsole' |
|
||||||
alias rdbm='rake db:migrate db:test:clone' |
|
||||||
alias rg='_rails_command generate' |
|
||||||
alias rgm='_rails_command generate migration' |
|
||||||
alias rp='_rails_command plugin' |
|
||||||
alias ru='_rails_command runner' |
|
||||||
alias rs='_rails_command server' |
|
||||||
alias rsd='_rails_command server --debugger' |
|
||||||
alias devlog='tail -f log/development.log' |
|
||||||
alias testlog='tail -f log/test.log' |
|
||||||
alias prodlog='tail -f log/production.log' |
|
||||||
alias rdm='rake db:migrate' |
|
||||||
alias rdc='rake db:create' |
|
||||||
alias rdr='rake db:rollback' |
|
||||||
alias rds='rake db:seed' |
|
||||||
alias rlc='rake log:clear' |
|
||||||
alias rn='rake notes' |
|
||||||
alias rr='rake routes' |
|
||||||
|
|||||||
@ -0,0 +1,9 @@ |
|||||||
|
#!/bin/zsh |
||||||
|
|
||||||
|
# WARP |
||||||
|
# ==== |
||||||
|
# oh-my-zsh plugin |
||||||
|
# |
||||||
|
# @github.com/mfaerevaag/wd |
||||||
|
|
||||||
|
alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh' |
||||||
@ -0,0 +1,201 @@ |
|||||||
|
#!/bin/zsh |
||||||
|
|
||||||
|
# WARP |
||||||
|
# ==== |
||||||
|
# Jump to custom directories in terminal |
||||||
|
# because `cd` takes too long... |
||||||
|
# |
||||||
|
# @github.com/mfaerevaag/wd |
||||||
|
|
||||||
|
|
||||||
|
## variables |
||||||
|
CONFIG=$HOME/.warprc |
||||||
|
|
||||||
|
## colors |
||||||
|
BLUE="\033[96m" |
||||||
|
GREEN="\033[92m" |
||||||
|
YELLOW="\033[93m" |
||||||
|
RED="\033[91m" |
||||||
|
NOC="\033[m" |
||||||
|
|
||||||
|
|
||||||
|
## load warp points |
||||||
|
typeset -A points |
||||||
|
while read line |
||||||
|
do |
||||||
|
arr=(${(s,:,)line}) |
||||||
|
key=${arr[1]} |
||||||
|
val=${arr[2]} |
||||||
|
|
||||||
|
points[$key]=$val |
||||||
|
done < $CONFIG |
||||||
|
|
||||||
|
|
||||||
|
## functions |
||||||
|
# prepended wd_ to not conflict with your environment (no sub shell) |
||||||
|
|
||||||
|
wd_warp() |
||||||
|
{ |
||||||
|
if [[ $1 =~ "^\.+$" ]] |
||||||
|
then |
||||||
|
if [[ $#1 < 2 ]] |
||||||
|
then |
||||||
|
wd_print_msg $YELLOW "Warping to current directory?" |
||||||
|
else |
||||||
|
(( n = $#1 - 1 )) |
||||||
|
wd_print_msg $BLUE "Warping..." |
||||||
|
cd -$n > /dev/null |
||||||
|
fi |
||||||
|
elif [[ ${points[$1]} != "" ]] |
||||||
|
then |
||||||
|
wd_print_msg $BLUE "Warping..." |
||||||
|
cd ${points[$1]} |
||||||
|
else |
||||||
|
wd_print_msg $RED "Unkown warp point '$1'" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
wd_add() |
||||||
|
{ |
||||||
|
if [[ $1 =~ "^\.+$" ]] |
||||||
|
then |
||||||
|
wd_print_msg $RED "Illeagal warp point (see README)." |
||||||
|
elif [[ ${points[$1]} == "" ]] || $2 |
||||||
|
then |
||||||
|
wd_remove $1 > /dev/null |
||||||
|
print "$1:$PWD" >> $CONFIG |
||||||
|
wd_print_msg $GREEN "Warp point added" |
||||||
|
else |
||||||
|
wd_print_msg $YELLOW "Warp point '$1' alredy exists. Use 'add!' to overwrite." |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
wd_remove() |
||||||
|
{ |
||||||
|
if [[ ${points[$1]} != "" ]] |
||||||
|
then |
||||||
|
if wd_tmp=`sed "/^$1:/d" $CONFIG` |
||||||
|
then |
||||||
|
echo $wd_tmp > $CONFIG |
||||||
|
wd_print_msg $GREEN "Warp point removed" |
||||||
|
else |
||||||
|
wd_print_msg $RED "Warp point unsuccessfully removed. Sorry!" |
||||||
|
fi |
||||||
|
else |
||||||
|
wd_print_msg $RED "Warp point was not found" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
wd_show() |
||||||
|
{ |
||||||
|
wd_print_msg $BLUE "Warp points to current directory:" |
||||||
|
wd_list_all | grep $PWD$ |
||||||
|
} |
||||||
|
|
||||||
|
wd_list_all() |
||||||
|
{ |
||||||
|
wd_print_msg $BLUE "All warp points:" |
||||||
|
while read line |
||||||
|
do |
||||||
|
if [[ $line != "" ]] |
||||||
|
then |
||||||
|
arr=(${(s,:,)line}) |
||||||
|
key=${arr[1]} |
||||||
|
val=${arr[2]} |
||||||
|
|
||||||
|
print "\t" $key "\t -> \t" $val |
||||||
|
fi |
||||||
|
done < $CONFIG |
||||||
|
} |
||||||
|
|
||||||
|
wd_print_msg() |
||||||
|
{ |
||||||
|
if [[ $1 == "" || $2 == "" ]] |
||||||
|
then |
||||||
|
print " $RED*$NOC Could not print message. Sorry!" |
||||||
|
else |
||||||
|
print " $1*$NOC $2" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
wd_print_usage() |
||||||
|
{ |
||||||
|
print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>" |
||||||
|
print "\nCommands:" |
||||||
|
print "\t add \t Adds the current working directory to your warp points" |
||||||
|
print "\t add! \t Overwrites existing warp point" |
||||||
|
print "\t remove Removes the given warp point" |
||||||
|
print "\t list \t Outputs all stored warp points" |
||||||
|
print "\t help \t Show this extremely helpful text" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
## run |
||||||
|
|
||||||
|
# get opts |
||||||
|
args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*` |
||||||
|
|
||||||
|
if [[ $? -ne 0 || $#* -eq 0 ]] |
||||||
|
then |
||||||
|
wd_print_usage |
||||||
|
else |
||||||
|
# can't exit, as this would exit the excecuting shell |
||||||
|
# e.i. your terminal |
||||||
|
|
||||||
|
#set -- $args # WTF |
||||||
|
|
||||||
|
for i |
||||||
|
do |
||||||
|
case "$i" |
||||||
|
in |
||||||
|
-a|--add|add) |
||||||
|
wd_add $2 false |
||||||
|
shift |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
-a!|--add!|add!) |
||||||
|
wd_add $2 true |
||||||
|
shift |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
-r|--remove|rm) |
||||||
|
wd_remove $2 |
||||||
|
shift |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
-l|--list|ls) |
||||||
|
wd_list_all |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
-h|--help|help) |
||||||
|
wd_print_usage |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
-s|--show|show) |
||||||
|
wd_show |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
*) |
||||||
|
wd_warp $i |
||||||
|
shift |
||||||
|
break |
||||||
|
;; |
||||||
|
--) |
||||||
|
shift; break;; |
||||||
|
esac |
||||||
|
done |
||||||
|
fi |
||||||
|
|
||||||
|
|
||||||
|
## garbage collection |
||||||
|
# if not, next time warp will pick up variables from this run |
||||||
|
# remember, there's no sub shell |
||||||
|
points="" |
||||||
|
args="" |
||||||
|
unhash -d val &> /dev/null # fixes issue #1 |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
# vim:ft=zsh ts=2 sw=2 sts=2 |
||||||
|
|
||||||
|
rvm_current() { |
||||||
|
rvm current 2>/dev/null |
||||||
|
} |
||||||
|
|
||||||
|
rbenv_version() { |
||||||
|
rbenv version 2>/dev/null | awk '{print $1}' |
||||||
|
} |
||||||
|
|
||||||
|
PROMPT=' |
||||||
|
%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} |
||||||
|
$ ' |
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}⭠ " |
||||||
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" |
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!" |
||||||
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" |
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN="" |
||||||
|
|
||||||
|
RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}' |
||||||
Loading…
Reference in new issue