我想在终端中制作动画光标提示(Ubuntu 14.04),
所以我制作这个脚本:
while [ : ]
do
echo -ne '|\r'
sleep 0.3
echo -ne '/\r'
sleep 0.3
echo -ne '一\r'
sleep 0.3
echo -ne '\\ \r'
sleep 0.3
echo -ne '|\r'
sleep 0.3
echo -ne '$\r'
sleep 0.3
done
But when i put it in the .bashrc ps1 ~/animated-prompt.sh &
it make a text distortion and every thing i write is overridden by the \r
character.
so Is there anyway to make this work ?
(IDK, like putting the script to another process thread other than the one that the terminal is working on)
保存并恢复光标位置而不是 \r。移动到您希望在保存和恢复光标位置之间出现动画的所需列位置。
对于光标移动,请参阅http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
修改后的脚本:
s="\033[s"
u="\033[u"
# Position of column
# As per my command prompt, i want 15th column( so 14C)
pos="\033[1000D\033[14C"
while [ : ]
do
eval echo -ne '$s$pos\|$u'
sleep 0.3
eval echo -ne '$s$pos/$u'
sleep 0.3
eval echo -ne '$s$pos一$u'
sleep 0.3
eval echo -ne '$s$pos\\\\$u'
sleep 0.3
eval echo -ne '$s$pos\|$u'
sleep 0.3
eval echo -ne '$s$pos\$$u'
sleep 0.3
done
[root@hello ~]|
正如您所使用的,它适用于 .bashrc 中的最后一行
Thanks
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)