From 70b4d2d2572779969c3b718977ee87c177af3e7e Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 21 Dec 2020 18:26:00 +0100 Subject: [PATCH] Fix some Ruby stuff --- bash/rc | 1 + shell/chruby | 7 ++++++- shell/kd | 2 +- shell/rbenv | 0 shell/ruby | 24 +++++++++++++++++++++--- zsh/rc | 1 + 6 files changed, 30 insertions(+), 5 deletions(-) mode change 100755 => 100644 shell/rbenv mode change 100644 => 100755 shell/ruby diff --git a/bash/rc b/bash/rc index f8bd87b..047c39e 100644 --- a/bash/rc +++ b/bash/rc @@ -10,6 +10,7 @@ source $DOTFILES_BASH_DIR/history source $DOTFILES_BASH_DIR/term_title source $DOTFILES_BASH_DIR/completion source $DOTFILES_SHELL_DIR/go +source $DOTFILES_SHELL_DIR/chruby source $DOTFILES_BASH_DIR/fzf source $DOTFILES_SHELL_DIR/git_prompt_info diff --git a/shell/chruby b/shell/chruby index 0783936..5f1090a 100755 --- a/shell/chruby +++ b/shell/chruby @@ -1,4 +1,6 @@ -if [[ -f $HOME/.nix-profile/share/chruby/chruby.sh ]]; then +if [[ -f /opt/arch/share/chruby/chruby.sh ]]; then + source /opt/arch/share/chruby/chruby.sh +elif [[ -f $HOME/.nix-profile/share/chruby/chruby.sh ]]; then source $HOME/.nix-profile/share/chruby/chruby.sh elif [[ -f /opt/arch/share/chruby/chruby.sh ]]; then source /opt/arch/share/chruby/chruby.sh @@ -29,6 +31,9 @@ _ruby-version() { } _auto-chruby() { + if ! type -f chruby > /dev/null 2>&1; then + return + fi local ruby_version=$(_ruby-version) if [[ -n "${ruby_version}" ]]; then chruby "${ruby_version}" diff --git a/shell/kd b/shell/kd index 9de040a..a6e67a3 100755 --- a/shell/kd +++ b/shell/kd @@ -7,7 +7,7 @@ function kd() { if [[ $# -eq 0 ]]; then local candidate="$PWD" while [[ -n "$candidate" ]]; do - for file in Gemfile Procfile .git; do + for file in Gemfile .git; do if [[ -e "$candidate/$file" ]]; then if [[ -t 1 ]]; then cd "$candidate" || return 1 diff --git a/shell/rbenv b/shell/rbenv old mode 100755 new mode 100644 diff --git a/shell/ruby b/shell/ruby old mode 100644 new mode 100755 index a57bc8d..1d607e5 --- a/shell/ruby +++ b/shell/ruby @@ -1,3 +1,21 @@ -GEM_HOME="$HOME/.gems" -export GEM_HOME -PATH=$PATH:"$GEM_HOME/bin" +# vim: ft=sh +# shellcheck shell=bash + +#ruby_version='2.7.0' +#GEM_HOME="$HOME/.gem/ruby/${ruby_version}" +#export GEM_HOME +#PATH=$PATH:"$GEM_HOME/bin" + +_auto-rubygems_gemdeps() { + local check_dir=$PWD + local next_check_dir=${check_dir%/*} + while [ "$next_check_dir" != "" ]; do + if [[ -f "$check_dir/Gemfile" ]]; then + export RUBYGEMS_GEMDEPS="$check_dir/Gemfile" + return + fi + check_dir="$next_check_dir" + next_check_dir=${check_dir%/*} + done + unset RUBYGEMS_GEMDEPS +} diff --git a/zsh/rc b/zsh/rc index 0ec1473..2b17273 100644 --- a/zsh/rc +++ b/zsh/rc @@ -37,6 +37,7 @@ chpwd() { __git_ps1_gitdir _gopath if _has-chruby; then _auto-chruby; fi + #_auto-rubygems_gemdeps } chpwd