2019-03-31 09:05:09 +00:00
.. _cmd-fish_prompt:
2018-12-17 01:39:33 +00:00
fish_prompt - define the appearance of the command line prompt
2019-01-03 04:10:47 +00:00
==============================================================
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
2021-12-17 23:16:47 +00:00
`` fish_prompt ``
2019-03-29 19:55:28 +00:00
::
function fish_prompt
...
end
2018-12-18 01:58:24 +00:00
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
2020-09-18 14:51:14 +00:00
The `` fish_prompt `` function is executed when the prompt is to be shown, and the output is used as a prompt.
2018-12-16 21:08:41 +00:00
2020-01-31 03:38:56 +00: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-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
`` fish `` ships with a number of example prompts that can be chosen with the `` fish_config `` command.
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Example
2019-01-03 04:10:47 +00:00
-------
2018-12-16 21:08:41 +00:00
A simple prompt:
2018-12-19 03:14:04 +00:00
::
function fish_prompt -d "Write out the prompt"
2020-10-02 17:02:10 +00:00
# This shows up as USER@HOST /home/user/ >, with the directory colored
# $USER and $hostname are set by fish, so you can just use them
# instead of using `whoami` and `hostname`
printf '%s@%s %s%s%s > ' $USER $hostname \
2020-06-17 18:45:04 +00:00
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
2018-12-19 03:14:04 +00:00
end
2018-12-16 21:08:41 +00:00