.bashrc: Watch

This commit is contained in:
2022-12-20 16:34:30 +01:00
parent 34451575a9
commit d933b8a830
2 changed files with 20 additions and 1 deletions

View File

@@ -106,6 +106,23 @@ Calls $cmd [...]"
$cmd $@
}
watch_modify() {
if [ $# -lt 2 ]; then
echo "Usage watch_modify FILE CMD ARGS...
Run CMD ARGS... when file FILE is updated
"
return
fi
file="$1"
base="$(basename "$file")"
dir="$(dirname "$file")"
inotifywait -r -m -e modify "$dir" | while read file_path file_event file_name; do
[ "$base" == "$file_name" ] && echo ${@:2} && ${@:2}
done
}
# Source git prompt
source_existing ~/scripts/git-prompt.sh
source_existing ~/.bash_prompt.kuba