Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9169875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:56:20+00:00 2026-06-17T15:56:20+00:00

This is a .bashrc question. I would like to set export FOO=bar for .bashrc

  • 0

This is a .bashrc question.
I would like to set "export FOO=bar" for .bashrc in a particular directory like .rvmrc.

I tried below.

$ touch ~/foo/.bashrc
$ echo 'export RAILS_ENV=development' >> ~/foo/.bashrc
$ cd foo/
$ env|grep RAILS_ENV

But RAILS_ENV shall be set nothing in this case.

If I set onto .rvmrc instead of .bashrc, it pass! But it is better way to set onto .bashrc because I do not need to install rvm environment.

Any solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:56:21+00:00Added an answer on June 17, 2026 at 3:56 pm

    in your bashrc set this:

    PROMPT_COMMAND='[[ $PWD == "/foo/bar/" ]] && export FOO=BAR || unset FOO'
    

    The contents of the PROMPT_COMMAND variable will be executed every time your prompt is rewritten ( just before it’s written actually ) the command above checks the $PWD variable ( which holds the current working directory of your shell ) against “/foo/bar” if it matches it exports your variable if it doesn’t then the variable is unset.

    EG

    peteches@yog-sothoth$ PROMPT_COMMAND='[[ $PWD == "/home/peteches/test" ]] && export FOO=BAR || unset FOO'
    peteches@yog-sothoth$ pwd
    /home/peteches
    peteches@yog-sothoth$ cd test
    peteches@yog-sothoth$ pwd
    /home/peteches/test
    peteches@yog-sothoth$ env | grep FOO
    6:FOO=BAR
    73:PROMPT_COMMAND=[[ $PWD == "/home/peteches/test" ]] && export FOO=BAR || unset FOO
    peteches@yog-sothoth$ cd ../
    peteches@yog-sothoth$ pwd
    /home/peteches
    peteches@yog-sothoth$ env | grep FOO
    72:PROMPT_COMMAND=[[ $PWD == "/home/peteches/test" ]] && export FOO=BAR || unset FOO
    peteches@yog-sothoth$ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tried to set some aliases in my .bashrc file. This one... export alias umusic=/Volumes/180
My .bashrc looks something like this... export PERL5LIB=/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0/${PLAT}-thread-multi export PERL5LIB=${PERL5LIB}:/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0 function dev { export
this is my first question in here, and I would like to ask if
I'd like to setup something like this in my .bashrc export p1=`eval echo ~/projects/customer
I added this line to my .bashrc (Ubuntu 9.10): export PYTHONPATH=/opt/google_appengine/ And then I
I am having trouble getting PYTHONPATH set. I have added this line to ~/.bashrc
HI i just run over a curious thing. In my .bashrc looks like this:
I want to make a alias, like this below gc this is a test
This is what I did: cd ~ touch .bashrc notepad .bashrc and the content
I add this line to /home/{user}/.bashrc file: export JAVA_HOME=/usr/lib/jvm/java-6-openjdk but when I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.