# type repeat ;echo "this is a bash shell output"
repeat is a function
repeat ()
{
local n i;
n="$1";
shift;
for ((i = 1; i <= "$n"; ++i))
do
echo Date starting `date`;
echo Before waiting `date`;
sleep 6;
echo Done waiting `date`;
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
"$@";
done
}
我想在 fish shell 中添加这个别名重复功能。这个别名已经在 bash shell 中可用,但我想在 fish shell 中也使用它。# 表示它是 root 用户。对于普通用户,它的 Fish shell 已被设置为默认。
答案1
function repeat
set n "$argv[1]";
set m "$argv[2]";
for i in (seq $n) ; set i $i+1
echo "Starting date";date
sleep 5;
echo "Before Waiting";date
sleep 10
echo "After Waiting";date
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
/usr/bin/mpv /usr/share/sounds/freedesktop/stereo/complete.oga;
eval $m
end
end
好吧,这就是我想到的答案,而且它有效。它使用 mpv 媒体播放器。如果可以进行任何进一步的更改,请告诉我。