From 1a95a6dd3b2805ccfebe42ceec5119e4f7857a26 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sun, 25 Oct 2020 16:15:07 +0100 Subject: [PATCH] Handy function to send push notification after long job --- .config/fish/config.fish | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 7233c01..dd8f00d 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -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