如何移动 figlet 输出
How to shift figlet output
我需要移动 FIGlet 输出(例如移动到终端的中心)。我怎样才能做到这一点?
我试过了
(tput sc ; tput cup 23 45 ; figlet text; tput rc)
但它不起作用。
并非必须使用 figlet,可以使用任何将文本转换为 "ascii art" 的程序。
谢谢!
Upd1:对不起,伙计们。 "centering" 只是一个例子。通常,我有必要将此文本移动到固定的行和列,例如
tput cup 10 10
~$ echo $'\r\r\r\r\r\r'; figlet ' text'
_ _
| |_ _____ _| |_
| __/ _ \ \/ / __|
| || __/> <| |_
\__\___/_/\_\__|
~$
居中很容易:
figlet -w $(tput cols) -c hello
-c
的意思是居中
-w num
设置figlet
的线宽
tput cols
returns当前终端的列
一般来说,您可以使用 -w
将 line width
设置为某个数字,比如 40
并使用 -c
,您将得到文本移动了...
$ figlet -w 30 -c hello
_ _ _
| |__ ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
$ figlet -w 50 -c hello
_ _ _
| |__ ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
此外,您可以通过在开头添加一些空格来移动输出,例如 sed
figlet hello | sed 's/^/ /'
或perl
figlet hello | perl -nle 'print " " x 30 . $_'
我需要移动 FIGlet 输出(例如移动到终端的中心)。我怎样才能做到这一点? 我试过了
(tput sc ; tput cup 23 45 ; figlet text; tput rc)
但它不起作用。
并非必须使用 figlet,可以使用任何将文本转换为 "ascii art" 的程序。
谢谢!
Upd1:对不起,伙计们。 "centering" 只是一个例子。通常,我有必要将此文本移动到固定的行和列,例如
tput cup 10 10
~$ echo $'\r\r\r\r\r\r'; figlet ' text'
_ _
| |_ _____ _| |_
| __/ _ \ \/ / __|
| || __/> <| |_
\__\___/_/\_\__|
~$
居中很容易:
figlet -w $(tput cols) -c hello
-c
的意思是居中-w num
设置figlet
的线宽
tput cols
returns当前终端的列
一般来说,您可以使用 -w
将 line width
设置为某个数字,比如 40
并使用 -c
,您将得到文本移动了...
$ figlet -w 30 -c hello
_ _ _
| |__ ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
$ figlet -w 50 -c hello
_ _ _
| |__ ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
此外,您可以通过在开头添加一些空格来移动输出,例如 sed
figlet hello | sed 's/^/ /'
或perl
figlet hello | perl -nle 'print " " x 30 . $_'