aboutsummaryrefslogtreecommitdiff
path: root/functions/alert.fish
blob: a21deac99b7cfde3fe786ffe2eed57a8f0c71fdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 functions -q notify
  if test $retval -eq 0
    notify "✅ Done: $cmd_str" "$output"
  else
    notify "❌ Failed $cmd_str" "$output"
  end
else
  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