auto-notify.plugin.zsh aktualisiert
This commit is contained in:
parent
86deef4ded
commit
f6c1f7fa35
1 changed files with 9 additions and 11 deletions
|
@ -7,6 +7,9 @@ export AUTO_NOTIFY_VERSION="0.10.2"
|
|||
[[ -z "$AUTO_NOTIFY_THRESHOLD" ]] &&
|
||||
export AUTO_NOTIFY_THRESHOLD=10
|
||||
|
||||
[[ -z "$AUTO_NOTIFY_PUBLISH" ]] &&
|
||||
export AUTO_NOTIFY_PUBLISH="zsh_events"
|
||||
|
||||
# List of commands/programs to ignore sending notifications for
|
||||
[[ -z "$AUTO_NOTIFY_IGNORE" ]] &&
|
||||
export AUTO_NOTIFY_IGNORE=(
|
||||
|
@ -41,11 +44,13 @@ function _auto_notify_message() {
|
|||
local exit_code="$3"
|
||||
local platform="$(uname)"
|
||||
# Run using echo -e in order to make sure notify-send picks up new line
|
||||
local DEFAULT_TITLE="ZSH: \"%command\" Completed"
|
||||
local DEFAULT_BODY="$(echo -e "Total time: %elapsed seconds\nExit code: %exit_code")"
|
||||
local DEFAULT_TITLE="ZSH: '%command' finished"
|
||||
local DEFAULT_BODY="$(echo -e "Time: %elapsed seconds elapsed\nExit code: %exit_code")"
|
||||
local DEFAULT_PUBLISH="zsh_events"
|
||||
|
||||
local title="${AUTO_NOTIFY_TITLE:-$DEFAULT_TITLE}"
|
||||
local text="${AUTO_NOTIFY_BODY:-$DEFAULT_BODY}"
|
||||
local publish="${AUTO_NOTIFY_PUBLISH:-$DEFAULT_PUBLISH}"
|
||||
|
||||
title="$(_auto_notify_format "$title" "$command" "$elapsed" "$exit_code")"
|
||||
body="$(_auto_notify_format "$text" "$command" "$elapsed" "$exit_code")"
|
||||
|
@ -60,7 +65,7 @@ function _auto_notify_message() {
|
|||
icon=${AUTO_NOTIFY_ICON_FAILURE:-""}
|
||||
fi
|
||||
|
||||
local arguments=("--title='$title'" "--priority=$urgency" "zsh_events" "$body")
|
||||
local arguments=("--title='$title'" "--priority=$urgency" $publish "$body")
|
||||
|
||||
ntfy publish -q ${arguments[@]}
|
||||
}
|
||||
|
@ -161,11 +166,4 @@ function enable_auto_notify() {
|
|||
|
||||
_auto_notify_reset_tracking
|
||||
|
||||
|
||||
platform="$(uname)"
|
||||
if [[ "$platform" == "Linux" ]] && ! type notify-send > /dev/null; then
|
||||
printf "'notify-send' must be installed for zsh-auto-notify to work\n"
|
||||
printf "Please install it with your relevant package manager\n"
|
||||
else
|
||||
enable_auto_notify
|
||||
fi
|
||||
enable_auto_notify
|
Loading…
Add table
Reference in a new issue