Skip to content
Snippets Groups Projects
Commit 0abedcc7 authored by nimrod's avatar nimrod
Browse files

Command notifier.

- Use notify-send to notify on finished (successfully or not) long
running commands (all commands, not just those with monitor).
- Move all Bash specifics together, under the if shell==bash clause and
to the end.
parent 6edf5d43
No related branches found
No related tags found
No related merge requests found
...@@ -46,10 +46,6 @@ export LESS_TERMCAP_se=$'\E[0m' ...@@ -46,10 +46,6 @@ export LESS_TERMCAP_se=$'\E[0m'
# Underline (dark grey). # Underline (dark grey).
export LESS_TERMCAP_us=$'\E[01;32m' export LESS_TERMCAP_us=$'\E[01;32m'
export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_ue=$'\E[0m'
export PS0="\$(__prerun)"
# shellcheck disable=SC1117
export PS1="\[\$(__prompt)\]\u@\h:\w\$ "
export CDPATH="$HOME:$HOME/Documents:$HOME/Documents/Shore:$HOME/Documents/Endless"
alias make='monitor make ' alias make='monitor make '
alias packer='monitor packer ' alias packer='monitor packer '
...@@ -265,24 +261,34 @@ __prompt () { ...@@ -265,24 +261,34 @@ __prompt () {
echo "$prompt" echo "$prompt"
} }
# shellcheck disable=SC1090 __prompt_command () {
. "$HOME/Documents/Shore/bundle_certs/bundle_certs" trap __command_notifier debug
}
if [ -n "${BASH:-}" ] __command_notifier () {
local exitstatus="$?"
local now runduration
now="$(date +%s)"
if [ -n "${last_finish:-}" ] && [ "$last_command" != "__prompt_command" ]
then then
shopt -s checkwinsize runduration="$(( now - last_finish ))"
shopt -s cmdhist if [ "$runduration" -gt "10" ]
# shellcheck disable=SC1091 then
[ -f /etc/bash_completion ] && . /etc/bash_completion if [ "$exitstatus" -eq "0" ]
then
notify-send "$last_command has finished."
else
notify-send "$last_command has failed."
fi
fi
fi
last_command="$BASH_COMMAND"
last_finish="$(date +%s)"
trap - debug
}
# shellcheck disable=SC1090 # shellcheck disable=SC1090
for sourcefile in "$HOME"/.bash_completion.d/* . "$HOME/Documents/Shore/bundle_certs/bundle_certs"
do
[ ! -f "$sourcefile" ] || . "$sourcefile"
done
! command -v direnv > /dev/null || eval "$(direnv hook bash)"
trap prune_prerun EXIT
fi
# make less more friendly for non-text input files, see lesspipe(1) # make less more friendly for non-text input files, see lesspipe(1)
...@@ -298,5 +304,26 @@ if [ -x /usr/bin/dircolors ]; then ...@@ -298,5 +304,26 @@ if [ -x /usr/bin/dircolors ]; then
alias less='less --raw-control-chars' alias less='less --raw-control-chars'
fi fi
prune_docker_remote if [ -n "${BASH:-}" ]
then
export CDPATH="$HOME:$HOME/Documents:$HOME/Documents/Shore:$HOME/Documents/Endless"
# shellcheck disable=SC2016
export PS0='$(__prerun)'
export PS1='\[$(__prompt)\]\u@\h:\w\$ '
export PROMPT_COMMAND='__prompt_command'
shopt -s checkwinsize
shopt -s cmdhist
# shellcheck disable=SC1091
[ -f /etc/bash_completion ] && . /etc/bash_completion
# shellcheck disable=SC1090
for sourcefile in "$HOME"/.bash_completion.d/*
do
[ ! -f "$sourcefile" ] || . "$sourcefile"
done
! command -v direnv > /dev/null || eval "$(direnv hook bash)"
prune_prerun prune_prerun
trap prune_prerun EXIT
fi
prune_docker_remote
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment