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 9141335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:37:53+00:00 2026-06-17T09:37:53+00:00

I don’t know how to make my requirement short in title, sorry if it

  • 0

I don’t know how to make my requirement short in title, sorry if it is not meaningful. I will explain here:

Many people put their dotfiles on bitbucket or github, to ease later installation or configuration, sync over different pc. I did the same, however I want to do something special, I am not sure how mecurial/git could help.

What I have:

I have 3 machines, say Home, Office and Client, all linux OS (could be different distributions). To make the example simple, say I just want to put one file the .zshrc into repo. The problem is, the three OS have different system variables(or other settings). e.g.

  • Office has JBOSS installed, then in .zshrc I need export JBOSS_HOME var.
  • Client has Oracle installed, then export different set of vars.
  • Office has to export HTTP_PROXY, but HOME not, Client needs it too, but different proxy value etc.

Now what I did is, I extract those machine specific settings (mostly export, alias statement) to another file, say myVar.sh. and source it at the end of the .zshrc.

So 3 machines have common part (same .zshrc), and different parts (myVar.sh).

What I want:

  • on any machine, if I found some nice settings, I change the .zshrc file (common part) and push. The changes should be easily sync to other machines (by pull, for example)

  • if I changed the myVar.sh (different part) on HOME, and push, it should not affect Office’s myVar.sh if I do pull on Office machine.

What I am doing:

now I have one Repo on bitBucket, and three branches (H,O,C). On Home PC, I just play with Home branch. Same for Office, Client.

The problem is, if I changed the common part on one pc, the change is in its own branch, a little bit difficult to sync to the other two. Because I would never merge those branches.

I also think about to mk different directories for different pc. e.g.

/.zshrc
|--/HOME/myVar.sh
|--/Office/myVar.sh
|--/Client/myVar.sh

and write shell script, e.g. check $HOST to decide writing myVar.sh to which directory. but I doubt that if it is the best way to achieve my goal. And when I look my dotfiles dir, I see all 3 pcs’ setting. I should be careful and enter the correct one to read the file.

In real world, the common part contains much more than .zhsrc (tmux,vimrc,xdefault..), so does the different part.

I don’t know can we somehow make a partial branch or do a partial merge on a repository…

I use hg much more than git, if hg can solve it I would prefer hg, if not, git is also acceptable. I don’t have much git experience except for clone, push, pull, up, merge,ci.

now, how should I do?

and, thank you for reading this…


EDIT more about the different part

I would thank you all guys for giving me answers. As I said above, the different part in my real machines is not as simple as myVar.sh. For example, I take my company-laptop (Office) to different clients (There are about 6 clients, not all clients provide us PCs, it is good because I could work with Linux everywhere), and configured printers for each by cups. I would put those configurations in Repo too. Because if one day I have to refresh my system, or harddisk failed, I could setup those printers very easy. Other things that belongs to different part but I cannot simply "source xxx" like

  • Xorg.conf for trackpoint

  • .hgrc file (since in company we have our own repo, uid, pwd, proxy..)

  • some pre-configured systemd modules, basically .conf files. But machine specific, e.g. radeon.conf only for my Home laptop. And Client pc has no systemd installed at all.

    That’s why I thought about different directory for PCs.

As I said right now I am with 3 branches way, and have a myConf directory, within this directory I have getConf.sh, to copy dotfiles, different confs etc to myConf. In fact the getConf.sh belongs to different part too, because the script is not same for all pcs.

Therefore I think the if-else/switch then source may not work in this case.

Yesterday I just took the .zshrc, and try to make the example simple. If it mislead you guys, sorry about that.

  • 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-17T09:37:54+00:00Added an answer on June 17, 2026 at 9:37 am

    My preferred way to do this is to have a host-specific version for each file all in the same directory — similar to your same file multiple directories, and then include it via variable interpolation in my main file. So ~/.bashrc has inside of this this:

    if [ -f ~/.bashrc-$HOSTNAME ] ; then
         source ~/.bashrc-$HOSTNAME
    fi
    

    Presumably that’s even prettier in zsh, but the idea is if a host-specific file exists source it at the end, and of course anything that applies on all machines goes in the main ~/.bashrc itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know why people do not practice AJAX implementation for authentication systems. Is it
Don't know why I can't reply to people on here with only a small
don't know better title for this, but here's my code. I have class user
Don't know a better title but here is what im trying to do. I
don't know if the title describes anything about what I'm trying to say but
Don't really know how to formulate the title, but it should be pretty obvious
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't know if I'm missing something here. I'd like to run multiple global variables
Don't know what's wrong here, when I run the application it says Specified method
Don't know if this is the right place to ask this, but I will

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.