Skip to content

Commit 8ed480c

Browse files
authored
Update rbenv module
1 parent c1bbcaf commit 8ed480c

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

modules/rbenv/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This script provides minimal working rbenv setup.
44
It can be used by importing its exported commands via:
55

66
```
7-
use path/to/rbenv.nu *
7+
use path/to/rbenv.nu
88
```
99

1010
With `path/to` being either the relative path of the file to your current working directory or its absolute path.

modules/rbenv/rbenv.nu

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
11
# rbenv
2-
export-env {
3-
load-env {
4-
PATH: ($env.PATH | split row (char esep) | prepend [$"($env.HOME)/.rbenv/bin" $"($env.HOME)/.rbenv/shims"])
5-
RBENV_VERSION: ""
6-
RBENV_VERSION_OLD: ""
7-
RBENV_SHELL: "nu"
8-
}
2+
export-env {
3+
use std/util "path add"
4+
5+
$env.RBENV_SHELL = 'nu'
6+
path add $"($env.HOME)/.rbenv/bin"
7+
path add $"($env.HOME)/.rbenv/shims"
98
}
109

11-
export def --env main [
12-
command?: string@'nu-complete rbenv',
13-
...args
14-
] {
15-
let new_env = if $command in ["rehash", "shell"] {
16-
# implement each on indiviudaly e.g.
17-
if $command == "shell" {
18-
{ RBENV_VERSION_OLD: $env.RBENV_VERSION RBENV_VERSION: $args.0 }
19-
} else {
20-
error make { msg: $"`($command)` command is not supported yet" }
21-
}
10+
export def --env "shell" [version: string] {
11+
let run = (^rbenv sh-shell $version | complete)
12+
if ($run.exit_code == 0) {
13+
$env.RBENV_VERSION_OLD = ($env.RBENV_VERSION | default "")
14+
$env.RBENV_VERSION = $version
2215
} else {
23-
if ($command | is-empty) {
24-
^rbenv
25-
} else {
26-
^rbenv $command $args
27-
}
28-
{}
16+
print -e $run.stderr
2917
}
30-
load-env $new_env
31-
}
32-
33-
def 'nu-complete rbenv' [] {
34-
^rbenv help
35-
| lines
36-
| where ($it | str starts-with " ")
37-
| each {|entry| $entry | split row ' ' | get 0 }
38-
}
18+
}

0 commit comments

Comments
 (0)