Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
037b39a8
Commit
037b39a8
authored
Nov 16, 2013
by
Sean Escriva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple plugin for chruby ruby version manager
parent
9f5a8951
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
chruby.plugin.zsh
plugins/chruby/chruby.plugin.zsh
+99
-0
No files found.
plugins/chruby/chruby.plugin.zsh
0 → 100644
View file @
037b39a8
#
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment