1
0
mirror of https://github.com/aquatix/dotfiles.git synced 2025-12-06 21:45:10 +01:00

Handy function to send push notification after long job

This commit is contained in:
2020-10-25 16:15:07 +01:00
parent dd536a69af
commit 1a95a6dd3b

View File

@@ -55,6 +55,9 @@ set -gx FZF_DEFAULT_COMMAND 'rg --files --no-ignore --hidden --follow --glob "!.
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND"
set -gx FZF_ALT_C_COMMAND "$FZF_DEFAULT_COMMAND"
# Set HOSTNAME to the hostname of the device, without trailing domain name
set -x HOSTNAME (hostname | string split -m1 '.')[1]
# Aliases
## Listing
alias ll 'ls -alF'
@@ -133,6 +136,24 @@ function rgvim
end
end
function imready
# Get return status and run time of last command, to be used with long-running jobs
# e.g.: longrunning.sh; imready
set laststatus $status
if test $status = 0
set result "success"
else
set result "failed with result $laststatus"
end
set duration (echo "$CMD_DURATION 1000" | awk '{printf "%.3fs", $1 / $2}')
set resulttext "Result of command: $result (took: $duration)"
# Send a push message with summary
if test -f "$HOME/workspace/projects/others/pushover.sh/pushover.sh"
$HOME/workspace/projects/others/pushover.sh/pushover.sh -t "[$HOSTNAME] command finished" "$resulttext"
end
end
function jl
# Pretty print the json file used as argument, and feed it in colour to less
jq -C --indent 2 . $argv | less -R