mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-29 07:49:20 +08:00
docs: Add fish_title and fish_greeting
This commit is contained in:
parent
36ed66beda
commit
5ae7be1603
doc_src/cmds
35
doc_src/cmds/fish_greeting.rst
Normal file
35
doc_src/cmds/fish_greeting.rst
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
.. _cmd-fish_greeting:
|
||||||
|
|
||||||
|
fish_greeting - display a welcome message in interactive shells
|
||||||
|
===============================================================
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
function fish_greeting
|
||||||
|
...
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
When an interactive fish starts, it executes fish_greeting and displays its output.
|
||||||
|
|
||||||
|
The default fish_greeting is a function that prints a variable of the same name (``$fish_greeting``), so you can also just change that if you just want to change the text.
|
||||||
|
|
||||||
|
While you could also just put ``echo`` calls into config.fish, fish_greeting takes care of only being used in interactive shells, so it won't be used e.g. with ``scp`` (which executes a shell), which prevents some errors.
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
A simple greeting:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
function fish_greeting
|
||||||
|
echo Hello friend!
|
||||||
|
echo The time is (set_color yellow; date +%T; set_color normal) and this machine is called $hostname
|
||||||
|
end
|
41
doc_src/cmds/fish_title.rst
Normal file
41
doc_src/cmds/fish_title.rst
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
.. _cmd-fish_title:
|
||||||
|
|
||||||
|
fish_title - define the terminal's title
|
||||||
|
========================================
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
function fish_title
|
||||||
|
...
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The ``fish_title`` function is executed before and after a new command is executed or put into the foreground and the output is used as a titlebar message.
|
||||||
|
|
||||||
|
The first argument to fish_title contains the most recently executed foreground command as a string, if any.
|
||||||
|
|
||||||
|
This requires that your terminal supports programmable titles and the feature is turned on.
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
A simple title:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
function fish_title
|
||||||
|
set -q argv[1]; or set argv fish
|
||||||
|
# Looks like ~/d/fish: git log
|
||||||
|
# or /e/apt: fish
|
||||||
|
echo (fish_prompt_pwd_dir_length=1 prompt_pwd): $argv;
|
||||||
|
end
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user