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

Mac终端如何修改默认启动目录?(macOS 10.12.4)

Fixing Terminal Default Startup Directory on macOS 10.12.4

Hey there! Let's get your Terminal to open directly to your coding folder on the desktop—your earlier attempt had a small misstep, so let's break this down clearly.

Why Your Previous Attempt Didn't Work

When you set "Shell opens with command" to cd desktop/coding, you told Terminal to run only that single command and then exit immediately. There's no interactive shell launched after the cd completes, which is why you saw "process done" and couldn't type anything. That setting is designed for one-off non-interactive commands, not configuring your default shell environment.

Solution 1: Use Terminal's Built-in Preferences (Easiest)

This is the simplest way to set a default working directory:

  • Open Terminal, then go to the top menu bar and select Terminal > Preferences (or press Cmd + ,).
  • Switch to the Profiles tab (the icon that looks like a user profile).
  • In the left sidebar, select your default profile (usually "Basic" unless you've customized it).
  • Go to the General sub-tab.
  • Under the "Working Directory" section, select Custom folder, then click the Choose button. Navigate to ~/Desktop/coding (make sure you pick the exact folder) and select it.
  • Close the Preferences window, then quit and restart Terminal—it should open directly to your coding folder now.

Solution 2: Modify Your Shell's Startup File (More Flexible)

If you want more control (like running other commands when Terminal starts), edit your shell's configuration file:

  1. Open Terminal (it'll start in your home directory for now).
  2. Type this command to open your bash profile in the nano text editor:
    nano ~/.bash_profile
    
  3. At the bottom of the file, add this line (using the absolute path avoids path-related issues):
    cd ~/Desktop/coding
    
  4. Press Ctrl + O to save the file, hit Enter to confirm the filename, then Ctrl + X to exit nano.
  5. To make the change take effect immediately, run:
    source ~/.bash_profile
    
    Or just quit and restart Terminal—next time it opens, you'll land right in your coding folder.

Either method should solve your problem—pick whichever feels more comfortable for you!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:14:01