From 32e833f3319e279167e3c4cf50f73b5ff93e4d65 Mon Sep 17 00:00:00 2001 From: axel Date: Sun, 4 Dec 2005 05:46:18 +1000 Subject: Remove old event hooks, add more event handler documentation darcs-hash:20051203194618-ac50b-e90683cb69b19da789152164a89a34bf187fd4e4.gz --- doc_src/doc.hdr | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'doc_src') diff --git a/doc_src/doc.hdr b/doc_src/doc.hdr index fb2ace9d..0f47bd52 100644 --- a/doc_src/doc.hdr +++ b/doc_src/doc.hdr @@ -757,9 +757,12 @@ order. If you want to run a command only on starting an interactive shell, use the output of the 'status --is-interactive' command. If you want to run a command only on starting a login shell, use 'status --is-login' instead. -If you want to run a set of commands when \c fish exits, redefine the -function hook \c fish_on_exit. If the \c -fish_on_exit is defined, it will be execute before the shell exits. +If you want to run a set of commands when \c fish exits, use an event +handler that is triggered by the exit of the shell: + +
function on_exit --on-process %self
+	echo fish is now exiting
+end
Universal variables are stored in the file .fishd.HOSTNAME, where HOSTNAME is the name of your @@ -841,15 +844,28 @@ end

-\subsection hooks Event hooks +\subsection event Event handlers + +When defining a new function in fish, it is possible to make it into an +event handler, i.e. a function that is automatically run when a +specific event takes place. Events that can trigger a handler currently are: + +* When a signal is delivered +* When a process or job exits +* When the value of a variable is updated + +Example: -There are several special function names in fish. If a function is -given this name, it will be automatically called when a specific event -has occured. These functions are: +To specify a signal handler for the WINCH signal, write: -- \c fish_on_exit, which is called before the shell exits -- \c fish_on_exec, which is called before interactively executing a command -- \c fish_on_return, which is called when control returns to the shell after interactively executing a command +
function --on-signal WINCH my_signal_handler
+	echo Got WINCH signal!
+end
+
+ +For more information on how to define new event handlers, see the +documentation for the function +command. \section issues Common issues with fish -- cgit v1.2.3