How to make an animated bash shell prompt for the terminal?

﹥>﹥吖頭↗ 提交于 2019-12-01 08:45:08

save and restore cursor position instead of \r. Move to required column location where you want animation between saving and restoring cursor position.

For cursor movement refer http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html

modified script:

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 ~]|

As you were using, it works with last line in .bashrc

Thanks

echo -ne '一\r'
#         ^
#         |
#         \--- problem

This character should be a hyphen, but is actually something called CJK Ideograph, First

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!