Fix some Ruby stuff

This commit is contained in:
Loic Nageleisen 2020-12-21 18:26:00 +01:00
parent f73e13ffeb
commit 70b4d2d257
6 changed files with 30 additions and 5 deletions

View file

@ -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}"

View file

@ -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

0
shell/rbenv Executable file → Normal file
View file

24
shell/ruby Normal file → Executable file
View file

@ -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
}