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
7b12fa97
Unverified
Commit
7b12fa97
authored
Dec 13, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(rbfu): clean up code
parent
e3bb6e68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
35 deletions
+42
-35
README.md
plugins/rbfu/README.md
+1
-0
rbfu.plugin.zsh
plugins/rbfu/rbfu.plugin.zsh
+41
-35
No files found.
plugins/rbfu/README.md
View file @
7b12fa97
...
...
@@ -4,6 +4,7 @@ This plugin starts [rbfu](https://github.com/hmans/rbfu), a minimal Ruby version
manager, and adds some useful functions.
To use it, add
`rbfu`
to the plugins array in your zshrc file:
```
zsh
plugins
=(
... rbfu
)
```
...
...
plugins/rbfu/rbfu.plugin.zsh
View file @
7b12fa97
...
...
@@ -5,38 +5,44 @@
# rvm_prompt_info function to return the $RBFU_RUBY_VERSION
# version.
command
-v
rbfu &>/dev/null
if
[[
$?
-eq
0
]]
;
then
eval
"
$(
rbfu
--init
--auto
)
"
# Internal: Print ruby version details, if it's currently
# active etc.
function
_rbfu_rubies_print
()
{
local
rb rb_out
rb
=
$(
basename
$1
)
rb_out
=
"
$rb
"
[[
-h
$1
]]
&&
rb_out
=
"
$rb_out
${
fg
[green]
}
@
${
reset_color
}
"
[[
"x
$rb
"
==
"x
$2
"
]]
&&
rb_out
=
"
${
fg
[red]
}
$rb_out
${
fg
[red]
}
*
${
reset_color
}
"
echo
$rb_out
}
# Public: Provide a list with all available rubies, this basically depends
# on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version
# and aliases.
function
rbfu-rubies
()
{
local
rbfu_dir active_rb
rbfu_dir
=
$RBFU_RUBIES
active_rb
=
$RBFU_RUBY_VERSION
[[
-z
"
$rbfu_dir
"
]]
&&
rbfu_dir
=
"
${
HOME
}
/.rbfu/rubies"
[[
-z
"
$active_rb
"
]]
&&
active_rb
=
"system"
_rbfu_rubies_print
"
${
rbfu_dir
}
/system"
$active_rb
for
rb
in
$(
ls
-1
$rbfu_dir
)
;
do
_rbfu_rubies_print
"
${
rbfu_dir
}
/
${
rb
}
"
$active_rb
done
}
# Public: Create rvm_prompt_info command for themes compatibility, unless
# it has already been defined.
[
!
-x
rvm_prompt_info
]
&&
function
rvm_prompt_info
()
{
echo
"
${
RBFU_RUBY_VERSION
:
=system
}
"
}
fi
command
-v
rbfu &>/dev/null
||
return
eval
"
$(
rbfu
--init
--auto
)
"
# Internal: Print ruby version details, if it's currently active, etc.
function
_rbfu_rubies_print
()
{
# 1: path to ruby file
# 2: active ruby
local
rb rb_out
rb
=
"
${
$1
:t
}
"
rb_out
=
"
$rb
"
# If the ruby is a symlink, add @ to the name.
if
[[
-h
"
$1
"
]]
;
then
rb_out
=
"
${
rb_out
}${
fg
[green]
}
@
${
reset_color
}
"
fi
# If the ruby is active, add * to the name and show it in red.
if
[[
"
$rb
"
=
"
$2
"
]]
;
then
rb_out
=
"
${
fg
[red]
}${
rb_out
}
${
fg
[red]
}
*
${
reset_color
}
"
fi
echo
$rb_out
}
# Public: Provide a list with all available rubies, this basically depends
# on ~/.rfbu/rubies. Highlights the currently active ruby version and aliases.
function
rbfu-rubies
()
{
local
rbfu_dir active_rb
rbfu_dir
=
"
${
RBFU_RUBIES
:-${
HOME
}
/.rbfu/rubies
}
"
active_rb
=
"
${
RBFU_RUBY_VERSION
:-
system
}
"
_rbfu_rubies_print
"
${
rbfu_dir
}
/system"
"
$active_rb
"
for
rb
in
${
rbfu_dir
}
/
*
(
N
)
;
do
_rbfu_rubies_print
"
$rb
"
"
$active_rb
"
done
}
# Public: Create rvm_prompt_info command for themes compatibility, unless
# it has already been defined.
[
!
-x
rvm_prompt_info
]
&&
function
rvm_prompt_info
()
{
echo
"
${
RBFU_RUBY_VERSION
:
=system
}
"
}
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