2019-03-31 17:05:09 +08:00
.. _cmd-fish_prompt:
2018-12-17 09:39:33 +08:00
fish_prompt - define the appearance of the command line prompt
2019-01-03 12:10:47 +08:00
==============================================================
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-03-30 03:55:28 +08:00
::
function fish_prompt
...
end
2018-12-18 09:58:24 +08:00
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
2018-12-20 04:02:45 +08:00
By defining the `` fish_prompt `` function, the user can choose a custom prompt. The `` fish_prompt `` function is executed when the prompt is to be shown, and the output is used as a prompt.
2018-12-17 05:08:41 +08:00
2020-01-31 11:38:56 +08:00
The exit status of commands within `` fish_prompt `` will not modify the value of :ref: `$status <variables-status>` outside of the `` fish_prompt `` function.
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` fish `` ships with a number of example prompts that can be chosen with the `` fish_config `` command.
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Example
2019-01-03 12:10:47 +08:00
-------
2018-12-17 05:08:41 +08:00
A simple prompt:
2018-12-19 11:14:04 +08:00
::
function fish_prompt -d "Write out the prompt"
printf '%s@%s%s%s%s> ' (whoami) (hostname | cut -d . -f 1) \
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
2018-12-17 05:08:41 +08:00