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

Fixes for shellcheck and shells that don't have history.

parent de801466
No related branches found
No related tags found
No related merge requests found
...@@ -99,20 +99,26 @@ alias bell='printf \a' ...@@ -99,20 +99,26 @@ alias bell='printf \a'
command -v notify-send > /dev/null || alias notify-send='bell' command -v notify-send > /dev/null || alias notify-send='bell'
monitor () { monitor () {
eval "$@" && notify-send "${1#__} has finished." || notify-send --urgency=critical "${1#__} has failed." if eval "$@"
then
notify-send "${1#__} has finished."
else
notify-send --urgency=critical "${1#__} has failed."
fi
} }
json_tool () { json_tool () {
if [ -t 0 ] if [ -t 0 ]
then then
python3 -m json.tool <<< "$*" | pygmentize -l javascript echo "$@" | python3 -m json.tool | pygmentize -l javascript
else else
python3 -m json.tool | pygmentize -l javascript python3 -m json.tool | pygmentize -l javascript
fi fi
} }
prune_prerun () { prune_prerun () {
local shell_procs="$(pgrep -u "$(id -u)" "$(basename $SHELL)")" local shell_procs
shell_procs="$(pgrep -u "$(id -u)" "$(basename "$SHELL")")"
for file in $HOME/.prerun.* for file in $HOME/.prerun.*
do do
echo "file" | grep -qv "$shell_procs" || rm "$file" echo "file" | grep -qv "$shell_procs" || rm "$file"
...@@ -250,6 +256,7 @@ __prerun () { ...@@ -250,6 +256,7 @@ __prerun () {
__prompt () { __prompt () {
local exitstatus="$?" local exitstatus="$?"
local runduration prompt local runduration prompt
! command -v history > /dev/null || history -a
prompt="" prompt=""
[ ! -f "$HOME/.prerun.$$" ] || runduration="$(__run_duration)" [ ! -f "$HOME/.prerun.$$" ] || runduration="$(__run_duration)"
[ "${runduration:-0}" -lt "10" ] || prompt="$(cyan -n "[Run duration: $runduration]") $prompt" [ "${runduration:-0}" -lt "10" ] || prompt="$(cyan -n "[Run duration: $runduration]") $prompt"
...@@ -266,7 +273,6 @@ then ...@@ -266,7 +273,6 @@ then
shopt -s histappend shopt -s histappend
shopt -s checkwinsize shopt -s checkwinsize
shopt -s cmdhist shopt -s cmdhist
export PROMPT_COMMAND="history -a"
[ -f /etc/bash_completion ] && . /etc/bash_completion [ -f /etc/bash_completion ] && . /etc/bash_completion
# shellcheck disable=SC1090 # shellcheck disable=SC1090
...@@ -274,7 +280,7 @@ then ...@@ -274,7 +280,7 @@ then
do do
[ ! -f "$sourcefile" ] || . "$sourcefile" [ ! -f "$sourcefile" ] || . "$sourcefile"
done done
! command -v direnv > /dev/null || eval $(direnv hook bash) ! command -v direnv > /dev/null || eval "$(direnv hook bash)"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment