Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reading ignored commands from a file #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ a new array.
# redefine what is ignored by auto-notify
export AUTO_NOTIFY_IGNORE=("docker" "man" "sleep")

Commands from the file auto-notify-ignored.txt are also also appended to the ``AUTO_NOTIFY_IGNORE`` variable.
This file is searched for in ``$ZDOTDIR``, or in your home dir if ``$ZDOTDIR`` isn't exported.
You might have to create it, it isn't there by default.
Each line in this file will be appended as one item (command) to the array.
If you wish to use custom location and/or name of the auto-notify-ignored.txt file,
then set ``AUTO_NOTIFY_IGNORE_FILE``` variable to your custom path.

::

# set custom path to an ignore file
export AUTO_NOTIFY_IGNORE_FILE="${HOME}/Documents/my-custom-ignore.txt"

**Using a Whitelist to ignore commands**

If you wish to use a whitelist approach instead of the default blacklist approach used by ``AUTO_NOTIFY_IGNORE``,
Expand Down
13 changes: 13 additions & 0 deletions auto-notify.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export AUTO_NOTIFY_VERSION="0.10.2"
# Threshold in seconds for when to automatically show a notification
[[ -z "$AUTO_NOTIFY_THRESHOLD" ]] &&
export AUTO_NOTIFY_THRESHOLD=10
# Path to auto-notify-ignored.txt - file with ignored commands
[[ -z "$AUTO_NOTIFY_IGNORE_FILE" ]] &&
export AUTO_NOTIFY_IGNORE_FILE="${ZDOTDIR:-$HOME}/auto-notify-ignored.txt"

# List of commands/programs to ignore sending notifications for
[[ -z "$AUTO_NOTIFY_IGNORE" ]] &&
Expand All @@ -24,6 +27,16 @@ export AUTO_NOTIFY_VERSION="0.10.2"
'nano'
)

# If AUTO_NOTIFY_WHITELIST isn't defined, read the file in AUTO_NOTIFY_IGNORE_FILE
# and append each line in that file to AUTO_NOTIFY_IGNORE array
if [[ -z "$AUTO_NOTIFY_WHITELIST" ]]; then
if [[ -e "$AUTO_NOTIFY_IGNORE_FILE" ]]; then
while IFS= read -r line; do
AUTO_NOTIFY_IGNORE+=("$line")
done < "$AUTO_NOTIFY_IGNORE_FILE"
fi
fi

function _auto_notify_format() {
local MESSAGE="$1"
local command="$2"
Expand Down