You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改MinGW的起始目录?含恢复原主目录的方法咨询

Hey there, let's get your MinGW terminal back to starting in your original home directory—here are three straightforward methods to fix this:

Method 1: Tweak the MinGW Shortcut Properties

This is the simplest fix if you launch MinGW via a desktop or Start Menu shortcut:

  • Locate the MinGW terminal shortcut you use (look on your desktop or in the MinGW folder in your Start Menu)
  • Right-click the shortcut and select Properties
  • Switch to the Shortcut tab
  • Find the Start in field: erase the current path and replace it with your original home directory (e.g., C:\Users\YourUsername—replace "YourUsername" with your actual Windows username)
  • Click Apply then OK. Next time you open the terminal, it’ll boot right into your desired directory.

Method 2: Edit the MinGW Startup Configuration File

If the shortcut fix doesn’t work, check if a startup script is overriding the directory:

  • Open your MinGW terminal (even if it’s in the wrong folder)
  • Type cd ~ to jump to your MinGW home directory (this should still point to your original home unless the HOME variable was changed)
  • Open the .bashrc file with a terminal editor—try nano .bashrc (easy for beginners) or vim .bashrc if you’re familiar with it
  • Scan the file for lines like cd /some/other/directory—this is probably what’s changing your startup folder. Either delete the line or comment it out by adding a # at the start (like # cd /some/other/directory)
  • Save the file (for nano, press Ctrl+O then Enter; for vim, type :wq and press Enter)
  • Close and reopen the terminal—it should now start in your original home directory.

Method 3: Reset the HOME Environment Variable

If MinGW’s home directory itself was changed, adjust the system environment variable:

  • Right-click This PC (or My Computer) and select Properties
  • Click Advanced system settings on the left sidebar
  • Go to the Advanced tab and click Environment Variables
  • Under User variables, look for a variable named HOME
  • If it’s set to a non-default path, click Edit and change the value to your original home directory (e.g., C:\Users\YourUsername)
  • Click OK on all open windows, then restart your MinGW terminal to apply the change.

Quick Tip

If you can’t remember your original home directory, open a regular Command Prompt and run echo %USERPROFILE%—this will show your default Windows user folder, which is MinGW’s default starting point.

内容的提问来源于stack exchange,提问作者heheheggg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:42:53