mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
Merge pull request #3003 from FSSlc/master
[Translated] 20150515 Lolcat--A Command Line Tool to Output Rainbow Of Colors in Linux Terminal.md
This commit is contained in:
commit
9bad3fff89
@ -1,178 +0,0 @@
|
||||
FSSlc translating
|
||||
|
||||
Lolcat – A Command Line Tool to Output Rainbow Of Colors in Linux Terminal
|
||||
================================================================================
|
||||
For those who believe that Linux Command Line is boring and there isn’t any fun, then you’re wrong here are the articles on Linux, that shows how funny and naughty is Linux..
|
||||
|
||||
- [20 Funny Commands of Linux or Linux is Fun in Terminal][1]
|
||||
- [6 Interesting Funny Commands of Linux (Fun in Terminal)][2]
|
||||
- [Fun in Linux Terminal – Play with Word and Character Counts][3]
|
||||
|
||||
Here in this article, I will be discussing about a small utility called “lolcat” – Which produce rainbow of colors in terminal.
|
||||
|
||||
![Lolcat Command to Output Rainbow of Colors for Terminal](http://www.tecmint.com/wp-content/uploads/2015/06/Linux-Lolcat.png)
|
||||
|
||||
Lolcat Command to Output Rainbow of Colors for Terminal
|
||||
|
||||
#### What is lolcat? ####
|
||||
|
||||
Lolcat is an utility for Linux, BSD and OSX which concatenates like similar to [cat command][4] and adds rainbow coloring to it. Lolcat is primarily used for rainbow coloring of text in Linux Terminal.
|
||||
|
||||
### Installation of Lolcat in Linux ###
|
||||
|
||||
**1. Lolcat utility is available in the repository of lots of Linux distributions, but the available version bit older. Alternatively you can download and install latest version of lolcat from git repository.**
|
||||
|
||||
Lolcat is a ruby gem hence it is essential to have latest version of RUBY installed on your system.
|
||||
|
||||
# apt-get install ruby [On APT based Systems]
|
||||
# yum install ruby [On Yum based Systems]
|
||||
# dnf install ruby [On DNF based Systems]
|
||||
|
||||
Once ruby package has been installed, make sure to verify the version of ruby installed.
|
||||
|
||||
# ruby --version
|
||||
|
||||
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
|
||||
|
||||
**2. Next download and install the most recent version of lolcat from the git repository using following commands.**
|
||||
|
||||
# wget https://github.com/busyloop/lolcat/archive/master.zip
|
||||
# unzip master.zip
|
||||
# cd lolcat-master/bin
|
||||
# gem install lolcat
|
||||
|
||||
Once lolcat is installed, you can check the version.
|
||||
|
||||
# lolcat --version
|
||||
|
||||
lolcat 42.0.99 (c)2011 moe@busyloop.net
|
||||
|
||||
### Usage of Lolcat ###
|
||||
|
||||
**3. Before starting usage of lolcat, make sure to know the available options and help using following command.**
|
||||
|
||||
# lolcat -h
|
||||
|
||||
![Lolcat Help](http://www.tecmint.com/wp-content/uploads/2015/06/Lolcat-Help1.png)
|
||||
|
||||
Lolcat Help
|
||||
|
||||
**4. Next, pipeline lolcat with commads say ps, date and cal as:**
|
||||
|
||||
# ps | lolcat
|
||||
# date | lolcat
|
||||
# cal | lolcat
|
||||
|
||||
![ps Command Output](http://www.tecmint.com/wp-content/uploads/2015/06/ps-command-output.png)
|
||||
|
||||
ps Command Output
|
||||
|
||||
![Date Output](http://www.tecmint.com/wp-content/uploads/2015/06/Date.png)
|
||||
|
||||
Date Output
|
||||
|
||||
![Calendar Output](http://www.tecmint.com/wp-content/uploads/2015/06/Cal.png)
|
||||
|
||||
Calendar Output
|
||||
|
||||
**5. 3. Use lolcat to display codes of a script file as:**
|
||||
|
||||
# lolcat test.sh
|
||||
|
||||
![Display Codes with Lolcat](http://www.tecmint.com/wp-content/uploads/2015/06/Script-Output.png)
|
||||
|
||||
Display Codes with Lolcat
|
||||
|
||||
**6. Pipeline lolcat with figlet command. Figlet is a utility which displays large characters made up of ordinary screen characters. We can pipeline the output of figlet with lolcat to make the output colorful as:**
|
||||
|
||||
# echo I ❤ Tecmint | lolcat
|
||||
# figlet I Love Tecmint | lolcat
|
||||
|
||||
![Colorful Texts](http://www.tecmint.com/wp-content/uploads/2015/06/Colorful-Text.png)
|
||||
|
||||
Colorful Texts
|
||||
|
||||
**Note**: Not to mention that ❤ is an unicode character and to install figlet you have to yum and apt to get the required packages as:
|
||||
|
||||
# apt-get figlet
|
||||
# yum install figlet
|
||||
# dnf install figlet
|
||||
|
||||
**7. Animate a text in rainbow of colours, as:**
|
||||
|
||||
$ echo I ❤ Tecmit | lolcat -a -d 500
|
||||
|
||||
![Animated Text](http://www.tecmint.com/wp-content/uploads/2015/06/Animated-Text.gif)
|
||||
|
||||
Animated Text
|
||||
|
||||
Here the option -a is for Animation and -d is for duration. In the above example duration count is 500.
|
||||
|
||||
**8. Read a man page (say man ls) in rainbow of colors as:**
|
||||
|
||||
# man ls | lolcat
|
||||
|
||||
![List Files Colorfully](http://www.tecmint.com/wp-content/uploads/2015/06/List-Files-Colorfully.png)
|
||||
|
||||
List Files Colorfully
|
||||
|
||||
**9. Pipeline lolcat with cowsay. cowsay is a configurable thinking and/or speaking cow, which supports a lot of other animals as well.**
|
||||
|
||||
Install cowsay as:
|
||||
|
||||
# apt-get cowsay
|
||||
# yum install cowsay
|
||||
# dnf install cowsay
|
||||
|
||||
After install, print the list of all the animals in cowsay as:
|
||||
|
||||
# cowsay -l
|
||||
|
||||
**Sample Output**
|
||||
|
||||
Cow files in /usr/share/cowsay/cows:
|
||||
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
|
||||
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
|
||||
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
|
||||
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
|
||||
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
|
||||
turtle tux unipony unipony-smaller vader vader-koala www
|
||||
|
||||
Output of cowsay pipelined with lolcat and ‘gnu‘ cowfile is used.
|
||||
|
||||
# cowsay -f gnu ☛ Tecmint ☚ is the best Linux Resource Available online | lolcat
|
||||
|
||||
![Cowsay with Lolcat](http://www.tecmint.com/wp-content/uploads/2015/06/Cowsay-with-Lolcat.png)
|
||||
|
||||
Cowsay with Lolcat
|
||||
|
||||
**Note**: You can use lolcat with any other command in pipeline and get colored output in terminal.
|
||||
|
||||
**10. You may create alias for the most frequently used commands to get command output in rainbow of colors. You can alias ‘ls -l‘ command which is used for long list the contents of directory as below.**
|
||||
|
||||
# alias lolls="ls -l | lolcat"
|
||||
# lolls
|
||||
|
||||
![Alias Commands with Colorful](http://www.tecmint.com/wp-content/uploads/2015/06/Alias-Commands-with-Colorful.png)
|
||||
|
||||
Alias Commands with Colorful
|
||||
|
||||
You may create alias for any command as suggested above. To create permanent alias, you have to add the relevant code (above code for ls -l alias) to ~/.bashrc file and also make sure to logout and login back for the changes to be taken into effect.
|
||||
|
||||
That’s all for now. I would like to know if you were aware of lolcat previously? Did you like the post? And suggestion and feedback is welcome in the comment section below. Like and share us and help us get spread.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/
|
||||
[2]:http://www.tecmint.com/linux-funny-commands/
|
||||
[3]:http://www.tecmint.com/play-with-word-and-character-counts-in-linux/
|
||||
[4]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
@ -0,0 +1,175 @@
|
||||
Lolcat – 一个在 Linux 终端中输出彩虹特效的命令行工具
|
||||
================================================================================
|
||||
那些相信 Linux 命令行是单调无聊且没有任何乐趣的人们,你们错了,这里有一些有关 Linux 的文章,它们展示着 Linux 是如何的有趣和“淘气” 。
|
||||
|
||||
- [20 个有趣的 Linux 命令或在终端中 Linux 是有趣的][1]
|
||||
- [6 个有趣的好玩 Linux 命令(在终端中的乐趣)][2]
|
||||
- [在 Linux 终端中的乐趣 – 把玩文字和字符计数][3]
|
||||
|
||||
在本文中,我将讨论一个名为“lolcat”的应用 – 它在终端中生成彩虹般的颜色。
|
||||
|
||||
![为终端生成彩虹般颜色的输出的 Lolcat 命令](http://www.tecmint.com/wp-content/uploads/2015/06/Linux-Lolcat.png)
|
||||
|
||||
为终端生成彩虹般颜色的输出的 Lolcat 命令
|
||||
|
||||
#### 何为 lolcat ? ####
|
||||
|
||||
Lolcat 是一个针对 Linux,BSD 和 OSX 平台的应用,它类似于 [cat 命令][4],并为 `cat` 的输出添加彩虹般的色彩。 Lolcat 原本用于在 Linux 终端中为文本添加彩虹般的色彩。
|
||||
|
||||
### 在 Linux 中安装 Lolcat ###
|
||||
|
||||
**1. Lolcat 应用在许多 Linux 发行版本的软件仓库中都可获取到,但可获得的版本都有些陈旧,而你可以通过 git 仓库下载和安装最新版本的 lolcat。**
|
||||
|
||||
由于 Lolcat 是一个 ruby gem 程序,所以在你的系统中安装有最新版本的 RUBY 是必须的。
|
||||
|
||||
# apt-get install ruby [在基于 APT 的系统中]
|
||||
# yum install ruby [在基于 Yum 的系统中]
|
||||
# dnf install ruby [在基于 DNF 的系统中]
|
||||
|
||||
一旦 ruby 软件包安装成功,请确保验证安装的 ruby 的版本。
|
||||
|
||||
# ruby --version
|
||||
|
||||
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
|
||||
|
||||
**2. 接着使用下面的命令来从 lolcat 的 git 仓库中下载和安装最新版本的 lolcat。**
|
||||
|
||||
# wget https://github.com/busyloop/lolcat/archive/master.zip
|
||||
# unzip master.zip
|
||||
# cd lolcat-master/bin
|
||||
# gem install lolcat
|
||||
|
||||
一旦 lolcat 安装后,你可以检查它的版本号。
|
||||
|
||||
# lolcat --version
|
||||
|
||||
lolcat 42.0.99 (c)2011 moe@busyloop.net
|
||||
|
||||
### Lolcat 的用法 ###
|
||||
|
||||
**3. 在开始使用 lolcat 之前,使用下面的命令来了解它可用的选项和其帮助文档。**
|
||||
|
||||
# lolcat -h
|
||||
|
||||
![Lolcat 的帮助文档](http://www.tecmint.com/wp-content/uploads/2015/06/Lolcat-Help1.png)
|
||||
|
||||
Lolcat 的帮助文档
|
||||
|
||||
**4. 接着, 通过管道连接 lolcat 和其他命令,例如 ps, date 和 cal:**
|
||||
|
||||
# ps | lolcat
|
||||
# date | lolcat
|
||||
# cal | lolcat
|
||||
|
||||
![ps 命令的输出](http://www.tecmint.com/wp-content/uploads/2015/06/ps-command-output.png)
|
||||
|
||||
ps 命令的输出
|
||||
|
||||
![Date 的输出](http://www.tecmint.com/wp-content/uploads/2015/06/Date.png)
|
||||
|
||||
Date 的输出
|
||||
|
||||
![Calendar 的输出](http://www.tecmint.com/wp-content/uploads/2015/06/Cal.png)
|
||||
|
||||
Calendar 的输出
|
||||
|
||||
**5. 使用 lolcat 来展示一个脚本文件的代码:**
|
||||
|
||||
# lolcat test.sh
|
||||
|
||||
![用 lolcat 来展示代码](http://www.tecmint.com/wp-content/uploads/2015/06/Script-Output.png)
|
||||
|
||||
用 lolcat 来展示代码
|
||||
|
||||
**6. 通过管道连接 lolcat 和 figlet 命令。Figlet 是一个展示由常规的屏幕字符组成的巨大字符串的应用。我们可以通过管道将 figlet 的输出连接到 lolcat 中来给出如下的多彩输出:**
|
||||
|
||||
# echo I ❤ Tecmint | lolcat
|
||||
# figlet I Love Tecmint | lolcat
|
||||
|
||||
![多彩的文字](http://www.tecmint.com/wp-content/uploads/2015/06/Colorful-Text.png)
|
||||
|
||||
多彩的文字
|
||||
|
||||
**注**: 毫无疑问 ❤ 是一个 unicode 字符并且为了安装 figlet,你需要像下面那样使用 yum 和 apt 来得到这个软件包:
|
||||
|
||||
# apt-get figlet
|
||||
# yum install figlet
|
||||
# dnf install figlet
|
||||
|
||||
**7. 给文本赋予彩虹颜色的动画:**
|
||||
|
||||
$ echo I ❤ Tecmit | lolcat -a -d 500
|
||||
|
||||
![动的文本](http://www.tecmint.com/wp-content/uploads/2015/06/Animated-Text.gif)
|
||||
|
||||
动的文本
|
||||
|
||||
这里选项 `-a` 指的是 Animation(动画), `-d` 指的是 duration(持续时间)。在上面的例子中,持续 500 次动画。
|
||||
|
||||
**8. 在彩虹般的颜色下阅读 man 页(例如 `man ls`):**
|
||||
|
||||
# man ls | lolcat
|
||||
|
||||
![多彩地显示文件](http://www.tecmint.com/wp-content/uploads/2015/06/List-Files-Colorfully.png)
|
||||
|
||||
多彩地显示文件
|
||||
|
||||
**9. 通过管道连接 lolcat 和 cowsay。cowsay 是一个可配置的正在思考或说话的奶牛,这个程序也支持其他的动物。**
|
||||
|
||||
使用下面的命令来安装 cowsay :
|
||||
|
||||
# apt-get cowsay
|
||||
# yum install cowsay
|
||||
# dnf install cowsay
|
||||
|
||||
安装后,使用下面的命令来显示在 cowsay 中的所有动物:
|
||||
|
||||
# cowsay -l
|
||||
|
||||
**样例输出**
|
||||
|
||||
Cow files in /usr/share/cowsay/cows:
|
||||
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
|
||||
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
|
||||
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
|
||||
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
|
||||
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
|
||||
turtle tux unipony unipony-smaller vader vader-koala www
|
||||
|
||||
通过管道连接 lolcat 和 cowsay 后的输出,并且使用了‘gnu’cowfile。
|
||||
|
||||
# cowsay -f gnu ☛ Tecmint ☚ is the best Linux Resource Available online | lolcat
|
||||
|
||||
![使用 Lolcat 的 Cowsay](http://www.tecmint.com/wp-content/uploads/2015/06/Cowsay-with-Lolcat.png)
|
||||
|
||||
使用 Lolcat 的 Cowsay
|
||||
|
||||
**注**: 你可以在管道中使用 lolcat 和其他任何命令来在终端中得到彩色的输出。
|
||||
|
||||
**10. 你可以为最常用的命令创建别名来使得命令的输出呈现出彩虹般的色彩。你可以像下面那样为 ‘ls -l‘ 命令创建别名,这个命令输出一个目录中包含内容的列表。**
|
||||
|
||||
# alias lolls="ls -l | lolcat"
|
||||
# lolls
|
||||
|
||||
![多彩的 Alias 命令](http://www.tecmint.com/wp-content/uploads/2015/06/Alias-Commands-with-Colorful.png)
|
||||
|
||||
多彩的 Alias 命令
|
||||
|
||||
你可以像上面建议的那样,为任何命令创建别名。为了使得别名永久生效,你必须添加相关的代码(上面的代码是 ls -l 的别名) 到 ~/.bashrc 文件中,并确保登出后再重新登录来使得更改生效。
|
||||
|
||||
现在就是这些了。我想知道你是否曾经注意过 lolcat 这个应用?你是否喜欢这篇文章?欢迎在下面的评论环节中给出你的建议和反馈。喜欢并分享我们,帮助我们传播。
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/
|
||||
[2]:http://www.tecmint.com/linux-funny-commands/
|
||||
[3]:http://www.tecmint.com/play-with-word-and-character-counts-in-linux/
|
||||
[4]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
Loading…
Reference in New Issue
Block a user