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

  • SEARCH
  • Home
  • 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 7752379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:47:06+00:00 2026-06-01T11:47:06+00:00

Generally I keep directory specific settings in .bashrc and whenever I change directory execute

  • 0

Generally I keep directory specific settings in .bashrc and whenever I change directory execute the command source .bashrc to make those settings effective.
Now I was thinking of manipulating cd command in ~/.bashrc, so whenever I cd to new directory and if any .bashrc exists there, it will be loaded automatically.

Similar to this cd $1; source .bashrc ( I have verified that $1 is valid path), but problem is cd is shell builting, so it’s a recursive loop ( cd always points to modifed cd ). We do not have elf file of cd ( which generally we have of other commands viz scp or others). So how can I achieve this ?
Also if shopt -s cdspell is supported then also I need to have cd spelled path in argument of $1.

  • 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-01T11:47:08+00:00Added an answer on June 1, 2026 at 11:47 am

    You want the “builtin” command;

    builtin shell-builtin [arguments]

    Execute the specified shell builtin,
    passing it arguments, and return its exit status. This is useful when
    defining a function whose name is the same as a shell builtin,
    retaining the functionality of the builtin within the function. The cd
    builtin is commonly redefined this way. The return status is false if
    shell-builtin is not a shell builtin command.

    From: http://linux.die.net/man/1/bash

    So, you could have something like (untested, don’t have a bash handy either);

    function cd() {
        builtin cd $1 \
            && test -e .bashrc \
            && source .bashrc
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I generally try and keep all related entities in the same repository. The following
I keep reading that, in C, using pointer arithmetic is generally faster than subscripting
I am looking generally in to Android development. I keep seeing information on root
Generally speaking, how can I keep a user from seeing a profile he has
I absolutely love the Keep Remote Directory Up-to-date feature in Winscp . Unfortunately, I
We have a project that references files in a Common-directory. Whenever that project is
I am new to programming in general so please keep that in mind when
In general, I don't like to keep code (BaseClasses or DataAccess Code) in the
Generally when I use ClickOnce when I build a VB.NET program but it has
Generally the database server is the biggest, most expensive box we have to buy

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.