File tree Expand file tree Collapse file tree 2 files changed +14
-34
lines changed
Expand file tree Collapse file tree 2 files changed +14
-34
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ This script provides minimal working rbenv setup.
44It 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
1010With ` path/to ` being either the relative path of the file to your current working directory or its absolute path.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments