FG

Set the title of the terminal window to the current directory

Fresh3 days ago
Mar 15, 202647691 views
Confidence Score1%
1%

Problem

How can I get the Terminal.app in OS X to display the current directory in its window or tab title? I'm using the bash shell.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Set the title of the terminal window to the current directory

Low Risk

Depends on your shell. This article displays multiple methods. I personally use zsh which has a convenient precmd() function which is run before each prompt. Although the other questions list bash methods, they alias cd. Bash provides an inherent method that chains off just the prompt. bash bash supplies a variable PROMPT_COMMAND which contains a command to execute before the prompt. This example (inserted in ~/.bashrc) sets the title to "username@hostname: directory": where \033 is the charact…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment