fish/functions/_sponge_on_postexec.fish 746 B raw
1
function _sponge_on_postexec --on-event fish_postexec
2
  set --global _sponge_current_command_exit_code $status
3
4
  # Remove command from the queue if it's been added previously
5
  if set --local index (contains --index -- $_sponge_current_command $_sponge_queue)
6
    set --erase _sponge_queue[$index]
7
  end
8
9
  # Ignore empty commands
10
  if test -n $_sponge_current_command
11
    set --local command ''
12
    # Run filters
13
    for filter in $sponge_filters
14
      if $filter \
15
          $_sponge_current_command \
16
          $_sponge_current_command_exit_code \
17
          $_sponge_current_command_previously_in_history
18
        set command $_sponge_current_command
19
        break
20
      end
21
    end
22
    set --prepend --global _sponge_queue $command
23
  end
24
end