Converted chruby to generic ruby (#437)

* Converted chruby to generic ruby

* Attempt at tests

* Only show the Ruby version if current directory has .rb files

* Only show the Ruby version if current directory has .rb files

* Revert "Only show the Ruby version if current directory has .rb files"

This reverts commit 136b02c1fd.

* Refactor

* Removed .tool-versions

* Sort configs

* Sort icons

* Remove pending changes

* Sort for remove_unusable_items

---------

Co-authored-by: Ilan Cosman <ilancosman@gmail.com>
This commit is contained in:
Carl Mercier 2023-09-14 00:06:56 -04:00 committed by GitHub
parent 1e08167a19
commit 9252158e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 44 additions and 35 deletions

View File

@ -1,3 +0,0 @@
function _tide_item_chruby
test -n "$RUBY_VERSION" && _tide_print_item chruby $tide_chruby_icon' ' $RUBY_VERSION
end

View File

@ -0,0 +1,6 @@
function _tide_item_ruby
if path is $_tide_parent_dirs/{*.gemspec,Gemfile,Rakefile,.ruby-version}
ruby --version | string match -qr "(?<v>[\d.]+)"
_tide_print_item ruby $tide_ruby_icon' ' $v
end
end

View File

@ -1,7 +1,7 @@
function _tide_remove_unusable_items function _tide_remove_unusable_items
# Remove tool-specific items for tools the machine doesn't have installed # Remove tool-specific items for tools the machine doesn't have installed
set -l removed_items set -l removed_items
for item in aws chruby crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi rustc terraform toolbox virtual_env for item in aws crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi ruby rustc terraform toolbox virtual_env
contains $item $tide_left_prompt_items $tide_right_prompt_items || continue contains $item $tide_left_prompt_items $tide_right_prompt_items || continue
set -l cli_names $item set -l cli_names $item

View File

@ -2,8 +2,6 @@ tide_aws_bg_color 444444
tide_aws_color FF9900 tide_aws_color FF9900
tide_character_color $_tide_color_green tide_character_color $_tide_color_green
tide_character_color_failure FF0000 tide_character_color_failure FF0000
tide_chruby_bg_color 444444
tide_chruby_color B31209
tide_cmd_duration_bg_color 444444 tide_cmd_duration_bg_color 444444
tide_cmd_duration_color 87875F tide_cmd_duration_color 87875F
tide_cmd_duration_decimals 0 tide_cmd_duration_decimals 0
@ -79,11 +77,13 @@ tide_pwd_color_dirs $_tide_color_dark_blue
tide_pwd_color_truncated_dirs 8787AF tide_pwd_color_truncated_dirs 8787AF
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix tide_right_prompt_prefix
tide_right_prompt_separator_diff_color tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color tide_right_prompt_separator_same_color
tide_right_prompt_suffix '' tide_right_prompt_suffix ''
tide_ruby_bg_color 444444
tide_ruby_color B31209
tide_rustc_bg_color 444444 tide_rustc_bg_color 444444
tide_rustc_color F74C00 tide_rustc_color F74C00
tide_shlvl_bg_color 444444 tide_shlvl_bg_color 444444

View File

@ -2,8 +2,6 @@ tide_aws_bg_color black
tide_aws_color yellow tide_aws_color yellow
tide_character_color brgreen tide_character_color brgreen
tide_character_color_failure brred tide_character_color_failure brred
tide_chruby_bg_color black
tide_chruby_color red
tide_cmd_duration_bg_color black tide_cmd_duration_bg_color black
tide_cmd_duration_color brblack tide_cmd_duration_color brblack
tide_context_bg_color black tide_context_bg_color black
@ -61,6 +59,8 @@ tide_pwd_bg_color black
tide_pwd_color_anchors brcyan tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan tide_pwd_color_dirs cyan
tide_pwd_color_truncated_dirs magenta tide_pwd_color_truncated_dirs magenta
tide_ruby_bg_color black
tide_ruby_color red
tide_rustc_bg_color black tide_rustc_bg_color black
tide_rustc_color red tide_rustc_color red
tide_shlvl_bg_color black tide_shlvl_bg_color black

View File

@ -2,8 +2,6 @@ tide_aws_bg_color normal
tide_aws_color FF9900 tide_aws_color FF9900
tide_character_color $_tide_color_green tide_character_color $_tide_color_green
tide_character_color_failure FF0000 tide_character_color_failure FF0000
tide_chruby_bg_color normal
tide_chruby_color B31209
tide_cmd_duration_bg_color normal tide_cmd_duration_bg_color normal
tide_cmd_duration_color 87875F tide_cmd_duration_color 87875F
tide_cmd_duration_decimals 0 tide_cmd_duration_decimals 0
@ -79,11 +77,13 @@ tide_pwd_color_dirs $_tide_color_dark_blue
tide_pwd_color_truncated_dirs 8787AF tide_pwd_color_truncated_dirs 8787AF
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled false tide_right_prompt_frame_enabled false
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix ' ' tide_right_prompt_prefix ' '
tide_right_prompt_separator_diff_color ' ' tide_right_prompt_separator_diff_color ' '
tide_right_prompt_separator_same_color ' ' tide_right_prompt_separator_same_color ' '
tide_right_prompt_suffix '' tide_right_prompt_suffix ''
tide_ruby_bg_color normal
tide_ruby_color B31209
tide_rustc_bg_color normal tide_rustc_bg_color normal
tide_rustc_color F74C00 tide_rustc_color F74C00
tide_shlvl_bg_color normal tide_shlvl_bg_color normal

View File

@ -2,8 +2,6 @@ tide_aws_bg_color normal
tide_aws_color yellow tide_aws_color yellow
tide_character_color brgreen tide_character_color brgreen
tide_character_color_failure brred tide_character_color_failure brred
tide_chruby_bg_color normal
tide_chruby_color red
tide_cmd_duration_bg_color normal tide_cmd_duration_bg_color normal
tide_cmd_duration_color brblack tide_cmd_duration_color brblack
tide_context_bg_color normal tide_context_bg_color normal
@ -61,6 +59,8 @@ tide_pwd_bg_color normal
tide_pwd_color_anchors brcyan tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan tide_pwd_color_dirs cyan
tide_pwd_color_truncated_dirs magenta tide_pwd_color_truncated_dirs magenta
tide_ruby_bg_color normal
tide_ruby_color red
tide_rustc_bg_color normal tide_rustc_bg_color normal
tide_rustc_color red tide_rustc_color red
tide_shlvl_bg_color normal tide_shlvl_bg_color normal

View File

@ -2,8 +2,6 @@ tide_aws_bg_color FF9900
tide_aws_color 232F3E tide_aws_color 232F3E
tide_character_color $_tide_color_green tide_character_color $_tide_color_green
tide_character_color_failure FF0000 tide_character_color_failure FF0000
tide_chruby_bg_color B31209
tide_chruby_color 000000
tide_cmd_duration_bg_color C4A000 tide_cmd_duration_bg_color C4A000
tide_cmd_duration_color 000000 tide_cmd_duration_color 000000
tide_cmd_duration_decimals 0 tide_cmd_duration_decimals 0
@ -79,11 +77,13 @@ tide_pwd_color_dirs E4E4E4
tide_pwd_color_truncated_dirs BCBCBC tide_pwd_color_truncated_dirs BCBCBC
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi chruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir tide_right_prompt_items status cmd_duration context jobs direnv node virtual_env rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir
tide_right_prompt_prefix tide_right_prompt_prefix
tide_right_prompt_separator_diff_color tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color tide_right_prompt_separator_same_color
tide_right_prompt_suffix '' tide_right_prompt_suffix ''
tide_ruby_bg_color B31209
tide_ruby_color 000000
tide_rustc_bg_color F74C00 tide_rustc_bg_color F74C00
tide_rustc_color 000000 tide_rustc_color 000000
tide_shlvl_bg_color 808000 tide_shlvl_bg_color 808000

View File

@ -2,8 +2,6 @@ tide_aws_bg_color yellow
tide_aws_color brblack tide_aws_color brblack
tide_character_color brgreen tide_character_color brgreen
tide_character_color_failure brred tide_character_color_failure brred
tide_chruby_bg_color red
tide_chruby_color black
tide_cmd_duration_bg_color yellow tide_cmd_duration_bg_color yellow
tide_cmd_duration_color black tide_cmd_duration_color black
tide_context_bg_color brblack tide_context_bg_color brblack
@ -61,6 +59,8 @@ tide_pwd_bg_color blue
tide_pwd_color_anchors brwhite tide_pwd_color_anchors brwhite
tide_pwd_color_dirs brwhite tide_pwd_color_dirs brwhite
tide_pwd_color_truncated_dirs white tide_pwd_color_truncated_dirs white
tide_ruby_bg_color red
tide_ruby_color black
tide_rustc_bg_color red tide_rustc_bg_color red
tide_rustc_color black tide_rustc_color black
tide_shlvl_bg_color yellow tide_shlvl_bg_color yellow

View File

@ -3,7 +3,6 @@ tide_character_icon
tide_character_vi_icon_default tide_character_vi_icon_default
tide_character_vi_icon_replace tide_character_vi_icon_replace
tide_character_vi_icon_visual V tide_character_vi_icon_visual V
tide_chruby_icon
tide_cmd_duration_icon tide_cmd_duration_icon
tide_crystal_icon tide_crystal_icon
tide_direnv_icon tide_direnv_icon
@ -26,6 +25,7 @@ tide_pulumi_icon 
tide_pwd_icon tide_pwd_icon
tide_pwd_icon_home tide_pwd_icon_home
tide_pwd_icon_unwritable tide_pwd_icon_unwritable
tide_ruby_icon
tide_rustc_icon tide_rustc_icon
tide_shlvl_icon tide_shlvl_icon
tide_status_icon tide_status_icon

View File

@ -1,15 +0,0 @@
# RUN: %fish %s
_tide_parent_dirs
function _chruby
_tide_decolor (_tide_item_chruby)
end
set -lx RUBY_VERSION
_chruby # CHECK:
set -lx RUBY_VERSION 3.0.0
set -lx tide_chruby_icon
_chruby # CHECK:  3.0.0

View File

@ -0,0 +1,21 @@
# RUN: %fish %s
_tide_parent_dirs
function _ruby
_tide_decolor (_tide_item_ruby)
end
set -l ruby_directory (mktemp -d)
cd $ruby_directory
mock ruby --version "echo 'ruby 3.2.0 (2022-12-25 revision a528908271) +YJIT [arm64-darwin22]'"
set -lx tide_ruby_icon
_ruby # CHECK:
touch Gemfile
_ruby # CHECK:  3.2.0
command rm -r $ruby_directory