PROMPT\_PWD(1) fish-shell PROMPT\_PWD(1)

# [NAME](#NAME)

prompt\_pwd - print pwd suitable for prompt

# [SYNOPSIS](#SYNOPSIS)

```
prompt_pwd
```

# [DESCRIPTION](#DESCRIPTION)

**prompt\_pwd** is a function to print the current working directory in a way suitable for prompts. It will replace the home directory with "~" and shorten every path component but the last to a default of one character.

To change the number of characters per path component, pass **--dir-length=** or set **fish\_prompt\_pwd\_dir\_length** to the number of characters. Setting it to 0 or an invalid value will disable shortening entirely. This defaults to 1.

To keep some components unshortened, pass **--full-length-dirs=** or set **fish\_prompt\_pwd\_full\_dirs** to the number of components. This defaults to 1, keeping the last component.

If any positional arguments are given, **prompt\_pwd** shortens them instead of **PWD** &lt;#envvar-PWD&gt;.

# [OPTIONS](#OPTIONS)

[**-d** or **--dir-length** *MAX*](#d)

Causes the components to be shortened to *MAX* characters each. This overrides **fish\_prompt\_pwd\_dir\_length**.

[**-D** or **--full-length-dirs** *NUM*](#D)

Keeps *NUM* components (counted from the right) as full length without shortening. This overrides **fish\_prompt\_pwd\_full\_dirs**.

[**-h** or **--help**](#h)

Displays help about using this command.

# [EXAMPLES](#EXAMPLES)

```
>_ cd ~/
>_ echo $PWD
/home/alfa
>_ prompt_pwd
~
>_ cd /tmp/banana/sausage/with/mustard
>_ prompt_pwd
/t/b/s/w/mustard
>_ set -g fish_prompt_pwd_dir_length 3
>_ prompt_pwd
/tmp/ban/sau/wit/mustard
>_ prompt_pwd --full-length-dirs=2 --dir-length=1
/t/b/s/with/mustard
>_ echo (prompt_pwd | string split /)[-1]
mustard
>_ echo (string join / (prompt_pwd | string split /)[-3..-1])
s/with/mustard
```

# [Copyright](#Copyright)

fish-shell developers

October 12, 2026 4.9

---

Document: prompt_pwd(1) from fish 4.9.3-r2 (Chainguard OS)
Source: https://github.com/fish-shell/fish-shell
