简体   繁体   中英

Cygwin starting directory using Windows Terminal

The guide at https://github.com/microsoft/terminal/blob/master/doc/user-docs/ThirdPartyToolProfiles.md suggests to use

{
    "name" : "Cygwin",
    "commandline" : "C:/Cygwin/bin/bash --login -i",
    "icon" : "C:/Cygwin/Cygwin.ico",
    "startingDirectory" : "C:/Cygwin/bin"
}

However, I'd like the startingDirectory to be $USERPROFILE . I have attempted various different methods to change the starting directory but they have all failed.

The trick is to use the chere package in Cygwin, which is used to solve the same problem. First ensure chere is installed in Cygwin. Then modify the commandline to the following:

                "name": "Cygwin",
                "commandline": "c:\\cygwin\\bin\\bash.exe /bin/xhere /bin/bash",
                "startingDirectory" : "%USERPROFILE%"

After this, you can change startingDirectory to any path.

Note, for those that are annoyed by the starting /bin/bash that is printed after launching Cygwin using this command you can simply comment out that line in /bin/xhere using the following sed one-liner sed -i -e 's|^\s*echo Starting $1;|# \0|' /bin/xhere sed -i -e 's|^\s*echo Starting $1;|# \0|' /bin/xhere

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM