Thread: MSYS Bash Configuration

  1. #1
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404

    MSYS Bash Configuration

    Hey guys,

    I've been setting up a dev environment on windows with MSYS, and I have been trying to configure the BASH shell. I've tried to keep the environment I'm creating isolated.

    I've made my new "HOME" a subdirectory of the location I've chosen. So my /home/user directory contains things like .bash_profile, .bashrc, etc. However, .bash_history has chosen to stay in what windows would consider my "HOME".

    Is there a way to get this to behave and use my specified "HOME"? Here is a snippet of my /etc/profile, which shows my reassignment of "HOME".

    Code:
    # Set up USER's home directory
    #if [ -z "$HOME" ]; then
      HOME="/e/msys/home/$LOGNAME"
    #fi
    
    if [ ! -d "$HOME" ]; then
      mkdir -p "$HOME"
      cp /etc/inputrc.default "$HOME"/.inputrc
    fi
    
    if [ "x$HISTFILE" == "x/.bash_history" ]; then
      HISTFILE=$HOME/.bash_history
    fi
    Any help would be appreciated. Thanks!

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Have you set your windows environment variable "HOME"?

    gg

  3. #3
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Well I didn't set it personally, the OS has for me. If I open a command prompt in windows, "HOME" points me to C:\Users\Myname. This is where .bash_history for some reason is getting saved.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    That's because Windows ENV vars become Bash's ENV vars as well. So $HOME is already defined when bash starts.

    >> ... the OS has for me
    The msys installer probably defaulted HOME to your user folder. Environment variable - Default Values on Microsoft Windows

    Run "sysdm.cpl" -> Advanced tab -> Environment Variables - set HOME to what you really want.

    gg

  5. #5
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    I'd like to leave windows $HOME the way it is. As I mentioned, I'm just trying to create an isolated environment. In my /etc/profile, I set $HOME to a completely new value, and everything seems to believe $HOME is where I told it to go, except for .bash_history. I feel like I'm missing the order of things and something else is loading before /etc/profile loads.
    The msys installer probably defaulted HOME to your user folder.
    I didn't use the installer. I grabbed all the bin/lib that I needed/wanted.

    This isn't a huge deal, just a minor inconvenience. I've learned a lot about the way shells work and all the configuration files that go along with them.

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Run "sysdm.cpl" -> Advanced tab -> Environment Variables - set HOME to what you really want.
    O_o

    It think he only wants to use a different `$(HOME)' for the "MSYS" environment.

    *shrug*

    Anyway, if I have my understanding right, change the `$(HOME)' environment variable within the script that loads the "MSYS" environment. (This is a "CMD", or Batch, script. This is not the shell script associated with "Bash".) I believe this is "MSYS.bat", but it has been a long time. (It is the one that initializes with `sh -i' I believe.)

    [Edit]
    Also, you'll need to revert this script to which I'm referring to the original state just in case.
    [/Edit]

    [Edit]
    The point of the change is moving your `$(Home)' directory before "MSYS" has a chance to use the one inherited from "Windows" proper.
    [/Edit]

    Soma
    Last edited by phantomotap; 04-22-2013 at 06:55 PM.

  7. #7
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Quote Originally Posted by phantomotap View Post
    Anyway, if I have my understanding right, change the `$(HOME)' environment variable within the script that loads the "MSYS" environment. (This is a "CMD", or Batch, script. This is not the shell script associated with "Bash".) I believe this is "MSYS.bat", but it has been a long time. (It is the one that initializes with `sh -i' I believe.)
    /facepalm

    I spent far too much time crawling through the MSYS scripts and forgot about the big picture. I did learn a lot though. It's probably not worth figuring out every little nuance of MSYS since it really is just an emulator, but it is pretty nifty for what I need to do.

    Thanks guys!

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    It's probably not worth figuring out every little nuance of MSYS since it really is just an emulator, but it is pretty nifty for what I need to do.
    O_o

    Well, you are certainly welcome, but "MSYS" is not really an emulator, and it is best not to think of it like one, primarily due to the general reasons for having "MSYS", because the "GCC" you should be using is the general "MinGW" build and not the "MSYS" build. (Of course, the fact that it is simply not an emulator is the biggest reason.)

    If this doesn't make sense, consider it this way: the "MSYS" build targets the "MSYS" environment which may tie applications to "MSYS" requiring that all machines where you wish to run the binary have "MSYS" installed (This is the exact opposite reason that "MSYS" exists. If you were going to subject yourself to that sort of requirement, "CYGWIN" would be better.) while the "MinGW" build simply targets "Windows" with a minimum level of the "MSVCRT" libraries available implying that virtually all "Windows" machines can run the binary without having "MSYS" or indeed any other supporting environment/libraries installed that aren't "just there out of the box". (You get to use the "*nix" environment either way because you have installed it.)

    Soma

  9. #9
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    That is primarily the reason I chose MSYS over cygwin; I don't want to depend upon the environment to run my programs. I do use a separate MinGW installation that I access through my MSYS environment for compiling/linking.

    I wasn't aware there was a way to build that would tie you to MSYS runtimes. I know there are some tool issues (like MinGW make vs MSYS make), but other than that, I've heard it is pretty lightweight.

  10. #10
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I wasn't aware there was a way to build that would tie you to MSYS runtimes. I know there are some tool issues (like MinGW make vs MSYS make), but other than that, I've heard it is pretty lightweight.
    O_o

    Well, yes, "MSYS" itself is lightweight, and yes, the code produced by the "MinGW" build does not tie you to "MSYS".

    Also though, you can use a specific build of "GCC", the "MSYS" specific build, that ties you to "MSYS", but you aren't using that, so it doesn't matter.

    Soma

  11. #11
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I'd like to leave windows $HOME the way it is.
    It was added by the msys installer. It's not a windows var (see link in post#4). Go-with-the-flow and customize it there.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I run ftp in line with Msys?
    By indigo0086 in forum Tech Board
    Replies: 5
    Last Post: 07-11-2007, 09:41 AM
  2. Help in samba configuration
    By lsme in forum Linux Programming
    Replies: 3
    Last Post: 11-10-2003, 09:11 AM
  3. Configuration Files
    By gvector1 in forum C# Programming
    Replies: 1
    Last Post: 10-30-2003, 04:21 PM
  4. Configuration File
    By gvector1 in forum C# Programming
    Replies: 0
    Last Post: 07-24-2003, 11:26 AM
  5. looking for files configuration
    By frigga in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-21-2002, 08:55 AM