我需要移动一个FIGlet输出(例如移动到终端的中心)。我怎样才能做到这一点? 我试过如何移动figlet输出
(tput sc ; tput cup 23 45 ; figlet text; tput rc)
但它不起作用。
使用figlet不是强制性的,可以使用任何将文本转换为“ascii art”的程序。
谢谢!
Upd1:对不起,伙计们。 “居中”只是一个例子。一般来说,有必要对我来说,这个文本固定行列数转移,像
tput cup 10 10
我需要移动一个FIGlet输出(例如移动到终端的中心)。我怎样才能做到这一点? 我试过如何移动figlet输出
(tput sc ; tput cup 23 45 ; figlet text; tput rc)
但它不起作用。
使用figlet不是强制性的,可以使用任何将文本转换为“ascii art”的程序。
谢谢!
Upd1:对不起,伙计们。 “居中”只是一个例子。一般来说,有必要对我来说,这个文本固定行列数转移,像
tput cup 10 10
定心很简单:
figlet -w $(tput cols) -c hello
-c
意味着中心-w num
设置的线宽为figlet
tput cols
返回当前终端的列在一般情况下,你可以使用-w
为line width
设置一些数字,让说40
和使用-c
,你会得到的文本移动。 ..
$ figlet -w 30 -c hello
_ _ _
| |__ ___| | | ___
| '_ \/_ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
$ figlet -w 50 -c hello
_ _ _
| |__ ___| | | ___
| '_ \/_ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
此外,还可以输出通过添加一些空格开始通过sed
figlet hello | sed 's/^/ /'
转移,例如
or perl
figlet hello | perl -nle 'print " " x 30 . $_'
~$ echo $'\r\r\r\r\r\r'; figlet ' text'
_ _
| |_ _____ _| |_
| __/ _ \ \//__|
| || __/> <| |_
\__\___/_/\_\\__|
~$
谢谢! sed或perl表达,我需要! – antonid