Add fish_job_summary, called whenever a job ends, stops, or is signalled

This allows users to customise the behaviour of the shell by redefining the function. This is similar to how fish_title or fish_greeting behave, where the default implementation can be easily overridden.

The function receives as arguments the job id, command line, signal name and signal description.
This commit is contained in:
Soumya
2020-04-29 21:14:12 -07:00
committed by Johannes Altmanninger
parent e3c4692031
commit 324fa64114
6 changed files with 114 additions and 53 deletions

39
tests/job_summary.expect Normal file
View File

@@ -0,0 +1,39 @@
# vim: set filetype=expect:
#
# Test job summary for interactive shells.
set pid [spawn $fish]
expect_prompt
send_line "function fish_job_summary; string join ':' \$argv; end"
expect_prompt
# fish_job_summary is called when background job ends.
send_line "sleep 0.5 &"
sleep 0.050
expect_prompt
sleep 0.550
expect -re "\[0-9]+:sleep 0.5 &:ENDED"
send_line ""
expect_prompt
# fish_job_summary is called when background job is signalled.
# cmd_line correctly prints only the actually backgrounded job.
send_line "false; sleep 10 &; true"
sleep 0.100
expect_prompt
exec -- pkill -TERM sleep -P $pid
sleep 0.100
expect -re "\[0-9]+:sleep 10 &:SIGTERM:Polite quit request"
send_line ""
expect_prompt
# fish_job_summary is called when foreground job is signalled.
# cmd_line contains the entire pipeline. proc_id and proc_name are set in a pipeline.
send_line "true | sleep 6"
sleep 0.100
exec -- pkill -KILL sleep -P $pid
sleep 0.100
expect -re "\[0-9]+:true | sleep 6:SIGKILL:Forced quit:\[0-9]+:sleep"
send_line ""
expect_prompt

View File

View File