-
-
Notifications
You must be signed in to change notification settings - Fork 192
Use bash globbing to set RUBIES #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
A shell-based solution would need to be portable to zsh since chruby support bash and zsh. For the moment, you can source chruby before you set your exa alias for a fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would need to either be implemented portably for bash/zsh or you could do a if statement with a bash- and zsh-specific version.
Adding proper ordering would be a real win.
share/chruby/chruby.sh
Outdated
@@ -1,10 +1,14 @@ | |||
CHRUBY_VERSION="0.3.9" | |||
RUBIES=() | |||
|
|||
saveglob="$(shopt -p nullglob dotglob)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In zsh, the shopt
equivalent would be setopt
.
for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do | ||
[[ -d "$dir" && -n "$(ls -A "$dir")" ]] && RUBIES+=("$dir"/*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing to consider is the sort order. In zsh, you can get a proper numeric sort fairly easily, so 2.10
is greater than 2.9
.
Here is a zsh one-liner.
echo "${(@n)RUBIES}"
Or to print each Ruby in order:
printf "%s\n" "${(@n)RUBIES:t}"
See #278 for a stab at numeric sorting. We discussed the possibility of creating a shell library for portable numeric sorting, since it's an annoying gap. I'm for switching to a portable shell solution but think it should fix the numeric sorting issue too. |
@havenwood I just pushed a new version of the code which should be |
Also this doesn't handle ordering. That looks hard to do in a portable fashion and I believe is out of scope for this PR. |
Ping. Please let me know if there are any changes I should make or if I should close this PR. Thanks! |
This is an alternative to #406. It fixes #413 and uses bash native functionality instead of
ls
at all. The impetus for this change is that an alias tols
breakschruby
. Specifically in my case I have:alias ls=exa
Which doesn't have a
-A
flag.