Skip to content

Commit

Permalink
Add support for multiple patterns in __done_exclude
Browse files Browse the repository at this point in the history
Closes ##99
  • Loading branch information
franciscolourenco committed Sep 27, 2023
1 parent 90eeefb commit 2986675
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ fisher update franciscolourenco/done
set -U __done_min_cmd_duration 5000 # default: 5000 ms
```

#### Prevent specific commands from triggering notifications. Accepts a regex.
#### Prevent specific commands from triggering notifications.

This is useful to exclude commands like `git commit` for instance, since it could trigger unwanted notifications if it is configured to use an external editor. This is also useful with `set -U __done_allow_nongraphical 1` to prevent notifications for commands normally run interactively that you do not want to get done notifications for.
It accepts a list of regex patterns.
This is useful to exclude commands like for instance `git commit`, since it could trigger unwanted notifications if it is configured to use an external editor. This is also useful with `set -U __done_allow_nongraphical 1` to prevent notifications for commands normally run interactively that you do not want to get done notifications for.

```fish
set -U __done_exclude 'git (?!push|pull)' # default: all git commands, except push and pull. accepts a regex.
set -U __done_exclude '^git (?!push|pull|fetch)' # default: all git commands, except push and pull. accepts a regex.
```

You can add more exclude patterns to the existing ones by using the `--append` option:

```fish
set -U --append __done_exclude '^emacsclient'
```

#### Execute a custom command instead of showing the default notifications. The `done` notification title and message can also be passed.
Expand Down
10 changes: 8 additions & 2 deletions conf.d/done.fish
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ end
if set -q __done_enabled
set -g __done_initial_window_id ''
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
set -q __done_exclude; or set -g __done_exclude 'git (?!push|pull|fetch)'
set -q __done_exclude; or set -g __done_exclude '^git (?!push|pull|fetch)'
set -q __done_notify_sound; or set -g __done_notify_sound 0
set -q __done_sway_ignore_visible; or set -g __done_sway_ignore_visible 0
set -q __done_tmux_pane_format; or set -g __done_tmux_pane_format '[#{window_index}]'
Expand All @@ -214,7 +214,13 @@ if set -q __done_enabled
if test $cmd_duration
and test $cmd_duration -gt $__done_min_cmd_duration # longer than notify_duration
and not __done_is_process_window_focused # process pane or window not focused
and not string match -qr $__done_exclude $argv[1] # don't notify on git commands which might wait external editor

# don't notify if command matches exclude list
for pattern in $__done_exclude
if string match -qr $pattern $argv[1]
return
end
end

# Store duration of last command
set -l humanized_duration (__done_humanize_duration "$cmd_duration")
Expand Down

0 comments on commit 2986675

Please sign in to comment.