want to use watch with my own command
[SOLVED] thanks to u/bac0on
i can now add this directly into .bash_aliases, or i can just paste the command into a terminal
alias las='
function what-changed() {
find -not \( -path './snap/firefox/common' -prune \) -not \( -path './.cache' -prune \) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10
};
export -f what-changed && watch -x bash -c what-changed'
thanks for everyone's help.
[/SOLVED]
—
i have this command used to find recently changed files.
find -not \( -path './snap/firefox/common' -prune \) -not \( -path './.cache' -prune \) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10
and i wanted to use watch to have it running in a window
however watch requires an executable, so i made a shell script that contained the command and then called
watch last_change
which works and allows me to make an alias for it .bash_aliases like
alias las='watch last_change'
all well and good
—
but then i had the bright idea to write this as a function instead of a script
function what-changed() {
find -not \( -path './snap/firefox/common' -prune \) -not \( -path './.cache' -prune \) -type f -mmin -1 -printf "%C+ %p\n" | sort -n | tail -10
};
watch what-changed
but it does not work.
watch says it can't find what-changed even tho it's right there and if i define this function in a console window, i can call it by itself and it will run.
but watch does not find it.
feels like i'm missing something simple, to help watch find it like it can find my script... something like a $PATH statement, but not that.
anyone see the issue?