aboutsummaryrefslogtreecommitdiff
path: root/functions/alert.fish
diff options
context:
space:
mode:
Diffstat (limited to 'functions/alert.fish')
-rw-r--r--functions/alert.fish19
1 files changed, 16 insertions, 3 deletions
diff --git a/functions/alert.fish b/functions/alert.fish
index d4e17dc..6ab53cb 100644
--- a/functions/alert.fish
+++ b/functions/alert.fish
@@ -1,9 +1,22 @@
function alert --description 'Report status of command to desktop'
+ set -l cmd $argv
+ set -l cmd_str (string join ' ' $cmd)
+ set -l output (eval $cmd 2>&1)
+ set -l retval $status
- if test $status -eq 0
- notify "✅ Done" (history | head -n1)
+ if functions -q notify
+ if test $retval -eq 0
+ notify "✅ Done: $cmd_str" "$output"
+ else
+ notify "❌ Failed $cmd_str" "$output"
+ end
else
- notify "❌ Failed" (history | head -n1)
+ if test $retval -eq 0
+ printf "✅ Done: %s\n%s\n" "$cmd_str" "$output"
+ else
+ printf "❌ Failed: %s\n%s\n" "$cmd_str" "$output"
+ end
end
+ return $retval
end