#shell_function

Todd A. Jacobs | Rubyisttodd_a_jacobs@ruby.social
2024-05-25

For anyone using the #fish_shell, the following #shell_function definition will let you switch to the latest CRuby #chruby knows about. It could be simplified (e.g. setting a function-local variable is mostly for debugging) or use builtins instead of pipes in shells where that matters, but I still find it useful for myself. Maybe you will, too.

```fish
function chruby-latest
set latest (
chruby | tr -d '*' |
pcregrep -o '\bruby-[\d.]+' | tail -1)
chruby $latest
end
```

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst