Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from chuckremes/.bashrc
Created May 6, 2010 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayneeseguin/392154 to your computer and use it in GitHub Desktop.
Save wayneeseguin/392154 to your computer and use it in GitHub Desktop.
# Check for an interactive session
if [[ ! -z "$PS1" ]] ; then
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
fi
# RVM
if [[ -s /home/cremes/.rvm/scripts/rvm ]] ; then source /home/cremes/.rvm/scripts/rvm ; fi
[cremes@box1 ~]$ rvm info
system:
uname: "Linux box1 2.6.33-ARCH #1 SMP PREEMPT Sun Apr 4 10:27:30 CEST 2010 x86_64 Intel(R) Xeon(R) CPU X5355 @ 2.66GHz GenuineIntel GNU/Linux"
shell: "bash"
version: "4.1.5(2)-release"
rvm:
type: "rvm is a function"
version: "rvm 0.1.29 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"
ruby:
interpreter: ""
version: ""
date: ""
platform: ""
patchlevel: ""
full_version: ""
homes:
gem: "'not set'"
ruby: "'not set'"
binaries:
ruby: ""
irb: ""
gem: ""
rake: ""
environment:
GEM_HOME: ""
GEM_PATH: ""
BUNDLE_PATH: ""
MY_RUBY_HOME: ""
IRBRC: ""
RUBYOPT: ""
gemset: ""
@chuckremes
Copy link

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:
The standard .bashrc contains a bad line of code that precludes certain scripts from executing. It has to do with
the logic for checking if the session is interactive.

e.g.
[ -z "$PS1" ] && return

Usually a few other lines are included afterward to, for example, alias 'ls' and to set PS1 to a new value.

Some scripts like rvm (rvm.beginrescueend.com) need to run at the tail end of the login process to tack on more data
to PATH or set other environment variables (think of it as a post-login hook). These kinds of scripts fail to execute
with the code above.

Repeat-By:
Login.

Fix:
Here's an alternate method to perform the interactive session check.

Check for an interactive session

if [[ ! -z "$PS1" ]] ; then
alias ls='ls --color=auto'
PS1='[\u@\h \W]$ '
fi

This allows scripts at the end of the .bashrc to be sourced/executed under all normal conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment