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