Make cygwin home directory to Windows' User Profile

前端 未结 3 969
忘掉有多难
忘掉有多难 2021-02-02 11:43

As I am developing Ruby on Rails on a Windows machine, I need to use cygwin to emulate the Unix command prompt. The problem now is that every time when I open the cygwin termina

相关标签:
3条回答
  • 2021-02-02 12:07
    mount -f "$USERPROFILE" ~
    mount -m > /etc/fstab
    

    Related

    Safely change home directory

    0 讨论(0)
  • 2021-02-02 12:07

    I was able to change mine by simply setting the HOME environment variable in Windows to C:\Users\MyUsername. When I start Cygwin, now it looks there. This has the added benefit of causing Emacs on regular Win32 (i.e., not via Cygwin) to start in the right place instead of in C:\Users\MyUsername\AppData\Roaming (and thus looking for .emacs and .emacs.d there)

    0 讨论(0)
  • 2021-02-02 12:22

    According to Cygwin documentation you can edit /etc/nsswitch.conf and change de db_home parameter.

    • %u - The Cygwin username (that's lowercase u).
    • %U - The Windows username (that's uppercase U).
    • %D - Windows domain in NetBIOS style.
    • %H - Windows home directory in POSIX style. Note that, for the db_home: setting,
    • %_ - Since space and TAB characters are used to separate the schemata, a space in the filename has to be given as %_ (that's an underscore).
    • %% - A per-cent character.

    Here is the content of my /etc/nsswitch.conf to create a home directory into each user directory

    # /etc/nsswitch.conf
    #
    #    This file is read once by the first process in a Cygwin process tree.
    #    To pick up changes, restart all Cygwin processes.  For a description
    #    see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch    
    # Defaults:
    # passwd:   files db
    # group:    files db
    # db_enum:  cache builtin
    # db_home: /home/%U <------ This was the default setting
    db_home: /%H/home # db_home: /home/%U <- This was the default setting
    # db_shell: /bin/bash
    # db_gecos: <empty>
    

    Restart any Cygwin process

    0 讨论(0)
提交回复
热议问题