Back to Fish

prompt_pwd - print pwd suitable for prompt¶

site/docs/3.2/cmds/prompt_pwd.html

latest1.0 KB
Original Source

This documents an old version of fish. See the latest release.

prompt_pwd - print pwd suitable for prompt

Synopsis

function fish\_promptecho -n (prompt\_pwd) '$ 'end

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, set $fish_prompt_pwd_dir_length to the number of characters. Setting it to 0 or an invalid value will disable shortening entirely.

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