2019-03-31 17:05:09 +08:00
.. _cmd-prompt_pwd:
2020-03-31 23:37:38 +08:00
prompt_pwd - print pwd suitable for prompt
2018-12-17 09:39:33 +08:00
==========================================
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
2019-09-17 17:59:04 +08:00
::
2018-12-18 09:58:24 +08:00
2019-09-17 17:59:04 +08:00
function fish_prompt
echo -n (prompt_pwd) '$ '
end
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-17 05:08:41 +08:00
2019-09-17 17:31:47 +08:00
`` 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.
2018-12-17 05:08:41 +08:00
2019-09-17 17:31:47 +08:00
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.
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Examples
2019-01-03 12:10:47 +08:00
--------
2018-12-17 05:08:41 +08:00
2018-12-19 11:14:04 +08:00
::
>_ cd ~/
>_ echo $PWD
2019-04-30 18:19:04 +08:00
/home/alfa
2019-09-17 16:50:52 +08:00
2018-12-19 11:14:04 +08:00
>_ prompt_pwd
2019-04-30 18:19:04 +08:00
~
2019-09-17 16:50:52 +08:00
2018-12-19 11:14:04 +08:00
>_ cd /tmp/banana/sausage/with/mustard
>_ prompt_pwd
2019-04-30 18:19:04 +08:00
/t/b/s/w/mustard
2019-09-17 16:50:52 +08:00
2018-12-19 11:14:04 +08:00
>_ set -g fish_prompt_pwd_dir_length 3
>_ prompt_pwd
2019-04-30 18:19:04 +08:00
/tmp/ban/sau/wit/mustard