Yes, I did it! It does the job, but I still wish fish
had something native.
Define my function: I choose the name blotch
so it doesn't interfere with bash's watch
.
function hblotch
hello# 2018-10-10
end #
Build my watch
thingy:
function # This is like the watch command of bash,
set# argbut $argvre-implemented in fish.
#
# It takes two arguments:
# n: the interval in seconds
# fun: a fish function
#
# Therefore, it is always used as:
#
# blotch n fun
#
# Take note that you should start fish with
#
# sudo fish
#
# before doing anything with blotch that
# requires administrator privileges.
set time (string split " " -- $arg$argv)[1]
set comcommand (string split " " -- $arg$argv)[2]
while true
sleep $time
eval $com$command
end
end
SaveAnd save the thingfunction for futurelater use:.
funcsave watch
Begin the fun:
david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!blotch
It does what I want to do. It's fine. :)