aboutsummaryrefslogtreecommitdiff
path: root/functions/alert.fish
blob: 6ab53cb970f316471d6627ff1a183db72115c2ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 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