Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions command/figlet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
figlet
===

字符串转为 “字画符”。

## 安装

+ Ubuntu 等系统

```shell
apt-get update
apt-get install -y figlet
```

+ CentOS 等系统

```shell
yum install epel-release
yum install -y figlet
```

## 概要

```shell
figlet [ message ] [ -option ]
```

## 主要用途

- 将普通字符串转为有简单字符拼接而成的 “字画符”。

## 参数

message 是需要转换的字符串。
当没有输入 message 时,会读取标准输入,因此可以配合管道符等使用。

## 选项

```shell
-w 限制输出宽度,默认为 '80'
-c 居中显示
-f 指定字体,默认为 'standard'
-k 保留字符之间的空隙
-t 对齐宽度到当前终端的宽度,这个参数优先级比 -w 高
-v 显示版本信息
```

## 返回值

字符串,由简单字符拼接而成的 “字画符”。

## 示例

- 从参数输入

```shell
figlet 'Hello, World!'
```

<pre style="line-height:1.2;">
_ _ _ _ __ __ _ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___( ) \_/\_/ \___/|_| |_|\__,_(_)
</pre>

- 配合管道符输入

```shell
echo 'Hello, World!' | figlet
```

<pre style="line-height:1.2;">
_ _ _ _ __ __ _ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___( ) \_/\_/ \___/|_| |_|\__,_(_)
</pre>

- 限制宽度

```shell
figlet 'Hello, World!' -w 40
```

<pre style="line-height:1.2;">
_ _ _ _
| | | | ___| | | ___
| |_| |/ _ \ | |/ _ \
| _ | __/ | | (_) |
|_| |_|\___|_|_|\___( )
|/
__ __ _ _ _
\ \ / /__ _ __| | __| | |
\ \ /\ / / _ \| '__| |/ _` | |
\ V V / (_) | | | | (_| |_|
\_/\_/ \___/|_| |_|\__,_(_)
</pre>

- 居中显示

```shell
figlet 'Hello, World!' -w 40 -c
```

<pre style="line-height:1.2;">
_ _ _ _
| | | | ___| | | ___
| |_| |/ _ \ | |/ _ \
| _ | __/ | | (_) |
|_| |_|\___|_|_|\___( )
|/
__ __ _ _ _
\ \ / /__ _ __| | __| | |
\ \ /\ / / _ \| '__| |/ _` | |
\ V V / (_) | | | | (_| |_|
\_/\_/ \___/|_| |_|\__,_(_)
</pre>

- 指定字体

```shell
figlet 'Hello, World!' -w 40 -c -f slant
```

<pre style="line-height:1.2;">
__ __ ____
/ / / /__ / / /___
/ /_/ / _ \/ / / __ \
/ __ / __/ / / /_/ /
/_/ /_/\___/_/_/\____( )
|/
_ __ __ ____
| | / /___ _____/ /___/ / /
| | /| / / __ \/ ___/ / __ / /
| |/ |/ / /_/ / / / / /_/ /_/
|__/|__/\____/_/ /_/\__,_(_)
</pre>

- 保留字符之间的空隙

```shell
figlet 'Hello, World!' -w 40 -c -k
```

<pre style="line-height:1.2;">
_ _ _ _
| | | | ___ | || | ___
| |_| | / _ \| || | / _ \
| _ || __/| || || (_) |_
|_| |_| \___||_||_| \___/( )
|/
__ __ _ _ _
\ \ / /___ _ __ | | __| || |
\ \ /\ / // _ \ | '__|| | / _` || |
\ V V /| (_) || | | || (_| ||_|
\_/\_/ \___/ |_| |_| \__,_|(_)
</pre>