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

@ -10,6 +10,7 @@ source $DOTFILES_BASH_DIR/history
source $DOTFILES_BASH_DIR/term_title source $DOTFILES_BASH_DIR/term_title
source $DOTFILES_BASH_DIR/completion source $DOTFILES_BASH_DIR/completion
source $DOTFILES_SHELL_DIR/go source $DOTFILES_SHELL_DIR/go
source $DOTFILES_SHELL_DIR/chruby
source $DOTFILES_BASH_DIR/fzf source $DOTFILES_BASH_DIR/fzf
source $DOTFILES_SHELL_DIR/git_prompt_info source $DOTFILES_SHELL_DIR/git_prompt_info

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 source $HOME/.nix-profile/share/chruby/chruby.sh
elif [[ -f /opt/arch/share/chruby/chruby.sh ]]; then elif [[ -f /opt/arch/share/chruby/chruby.sh ]]; then
source /opt/arch/share/chruby/chruby.sh source /opt/arch/share/chruby/chruby.sh
@ -29,6 +31,9 @@ _ruby-version() {
} }
_auto-chruby() { _auto-chruby() {
if ! type -f chruby > /dev/null 2>&1; then
return
fi
local ruby_version=$(_ruby-version) local ruby_version=$(_ruby-version)
if [[ -n "${ruby_version}" ]]; then if [[ -n "${ruby_version}" ]]; then
chruby "${ruby_version}" chruby "${ruby_version}"

View file

@ -7,7 +7,7 @@ function kd() {
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
local candidate="$PWD" local candidate="$PWD"
while [[ -n "$candidate" ]]; do while [[ -n "$candidate" ]]; do
for file in Gemfile Procfile .git; do for file in Gemfile .git; do
if [[ -e "$candidate/$file" ]]; then if [[ -e "$candidate/$file" ]]; then
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
cd "$candidate" || return 1 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" # vim: ft=sh
export GEM_HOME # shellcheck shell=bash
PATH=$PATH:"$GEM_HOME/bin"
#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
}

1
zsh/rc
View file

@ -37,6 +37,7 @@ chpwd() {
__git_ps1_gitdir __git_ps1_gitdir
_gopath _gopath
if _has-chruby; then _auto-chruby; fi if _has-chruby; then _auto-chruby; fi
#_auto-rubygems_gemdeps
} }
chpwd chpwd