mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-24 22:11:20 +02:00
batwatch: small formatting changes
This commit is contained in:
parent
990a1dc397
commit
69d9c38326
@ -75,23 +75,19 @@ determine_stat_variant() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local varient name cmd ts
|
local variant name flags ts
|
||||||
|
for variant in "gnu -c %Z" "bsd -f %m"; do
|
||||||
for varient in "gnu -c %Z" "bsd -f %m"; do
|
read -r name flags <<< "$variant"
|
||||||
read -r name flags <<< "$varient"
|
|
||||||
|
|
||||||
# save the results of the stat command
|
# save the results of the stat command
|
||||||
if read -r ts < \
|
if read -r ts < <(stat ${flags} "$0" 2>/dev/null); then
|
||||||
<( stat ${flags} "$0" 2>/dev/null ); then
|
|
||||||
|
|
||||||
# verify that the value is an epoch timetamp
|
# verify that the value is an epoch timestamp
|
||||||
# before proceeding
|
# before proceeding
|
||||||
if [[ "${ts}" =~ ^[0-9]+$ ]]; then
|
if [[ "${ts}" =~ ^[0-9]+$ ]]; then
|
||||||
|
|
||||||
POLL_STAT_COMMAND=(stat ${flags})
|
POLL_STAT_COMMAND=(stat ${flags})
|
||||||
POLL_STAT_VARIANT="$name"
|
POLL_STAT_VARIANT="$name"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -130,6 +126,7 @@ watcher_poll_watch() {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if the file has been modified.
|
||||||
local i=0
|
local i=0
|
||||||
for file in "${files[@]}"; do
|
for file in "${files[@]}"; do
|
||||||
time="$("${POLL_STAT_COMMAND[@]}" "$file")"
|
time="$("${POLL_STAT_COMMAND[@]}" "$file")"
|
||||||
@ -142,13 +139,12 @@ watcher_poll_watch() {
|
|||||||
((i++))
|
((i++))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Wait for "q" to exit, or check again after 1 second.
|
||||||
|
local input
|
||||||
read -r -t 1 input
|
read -r -t 1 input
|
||||||
|
|
||||||
if [[ "$input" =~ [q|Q] ]]; then
|
if [[ "$input" =~ [q|Q] ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
input=
|
|
||||||
done
|
done
|
||||||
|
|
||||||
"${POLL_STAT_COMMAND[@]}" "$@"
|
"${POLL_STAT_COMMAND[@]}" "$@"
|
||||||
@ -199,7 +195,6 @@ while shiftopt; do
|
|||||||
--watcher) shiftval; OPT_WATCHER="$OPT_VAL" ;;
|
--watcher) shiftval; OPT_WATCHER="$OPT_VAL" ;;
|
||||||
--clear) OPT_CLEAR=true ;;
|
--clear) OPT_CLEAR=true ;;
|
||||||
--no-clear) OPT_CLEAR=false ;;
|
--no-clear) OPT_CLEAR=false ;;
|
||||||
-h|--help) OPT_HELP=true ;;
|
|
||||||
|
|
||||||
# bat/Pager options
|
# bat/Pager options
|
||||||
-*) BAT_ARGS+=("$OPT=$OPT_VAL") ;;
|
-*) BAT_ARGS+=("$OPT=$OPT_VAL") ;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user