在 Linux 终端显示动画式 ASCII 生日祝福
生日 ASCII 艺术
![](/data/attachment/album/202307/13/162413kvclclvgvhj8qqbz.jpg)



> 
> 通过在 Linux 终端创建 ASCII 生日动画，让你所爱的人的特殊日子更加特别。
> 
> 
> 


生日是特殊的日子，从亲朋好友那里收到生日祝福是非常令人满足和愉悦的。


作为 Linux 用户，你可以通过终端给朋友和家人带来一些酷炫的生日祝福。


这是我为 Abhishek 先生的生日制作的生日卡片（或者说动画）。



我们团队的每个人都非常喜欢它，所以我受到请求要按照它做一个教程。我很乐意满足请求，因为这可能对我们的读者有所帮助 ?



> 
> ✋ 这个教程需要在终端中编辑配置文件。熟练使用 Linux 终端和命令会更容易理解和跟随本教程。
> 
> 
> 


### 安装 PyBirthdayWish


PyBirthdayWish 是一个小型的 Python 程序，通过它你可以创建漂亮的终端生日祝福，还可以播放音乐！


这个程序本身在 Ubuntu 的默认软件仓库中不可用，你需要使用 Pip 进行安装。



> 
> **[PyBirthdayWish GitHub](https://github.com:443/hemantapkh/PyBirthdayWish)**
> 
> 
> 


首先，使用以下命令在 Ubuntu 中 [安装 Pip](https://itsfoss.com/install-pip-ubuntu/)：



```
sudo apt install python3-pip

```

安装完 Pip 后，你可以克隆该存储库并安装该程序：



```
git clone https://github.com/hemantapkh/PyBirthdayWish.git && cd PyBirthdayWish && pip install -r requirements.txt

```

在他们的存储库中，你可以查看 `.requirements.txt` 文件，了解上述命令中所需的依赖项。


安装完成后，在你克隆的 `PyBirthdayWish` 目录中运行以下命令：



```
python3 PyBirthdayWish.py

```

这将要求你按下 `F11` 键，然后按回车键进入全屏模式，然后播放动画。


![](/data/attachment/album/202307/13/162515r8emeo8izzeh8doo.png)


![](/data/attachment/album/202307/13/162516wmqbr0a6w14c6rxr.png)


这里还有音乐，但这里没有展示。


它非常可定制化。**让我展示一下你可以通过这个工具进行的各种级别的可选定制。**


### 创建默认的生日祝福动画


在上述程序中，有三个用于动画的 Python 文件。它们是 `example`（默认）、`art` 和 `artwithstars`。你可以打开这三个文件来了解其内容。


![arts 目录的内容，其中包含默认和用户创建的 art 文件](/data/attachment/album/202307/13/162516rf0fzqdcf009hfrx.png)


现在，如果你想使用 `artwithstars` 文件代替默认的 `example` 文件，在 [任何可用的文本编辑器](https://itsfoss.com/command-line-text-editors-linux/) 中打开 `config.py`，将 `arts` 的条目替换为所需的名称，然后保存，如下面的截图所示：


![在配置文件中将动画设计文件更改为 "art with stars"](/data/attachment/album/202307/13/162517xz2pddghuyp5yn4b.png)


之后，在 `PyBirthdayWish` 目录中运行：



```
python3 PyBirthdayWish.py

```

你将得到新的动画效果。


### 创建自定义的生日祝福


如果你想打印你所爱的人的名字，而不是默认的文字，这需要一点耐心，因为你需要在不破坏原文件的情况下编辑 art 文件。


首先，备份你想要的设计 art 文件。即在同一个 `arts` 目录中将文件复制一份，并给它一个不同的名称，比如 `friend.py`。


现在，用你选择的文本编辑器打开设计 art 文件。将文件中的文字替换为你需要的内容。最好使用符号 `| _ \ /` 等来创建文本和设计。你可以使用一个 [在线工具将文字转换为 ASCII 艺术](https://patorjk.com:443/software/taag/#p=display&f=Big&t=Friend)。


![复制了一个现有的设计文件，并添加了一个新的文字 "Friend"](/data/attachment/album/202307/13/162517so44o9hld8llrl49.png)



> 
> ? 输入一个字符将使动画的其余部分向前移动一个字符。同样，删除一个字符会使设计的其余部分向后移动一个字符。因此，如果删除一个字符，请添加一个空格。同样地，如果在某一行上添加了一个新字符，请删除一个空格。这应该实时进行，这样你就可以查看更改。这样，你就可以使剩余的设计匹配，并在完成时保持外观不变。
> 
> 
> 


编辑完成后保存文件。现在，打开 `config.py` 并将 art 文件更改为你的文件，以显示你所做的更改。


![在配置文件中更改设计文件以反映我们所做的更改](/data/attachment/album/202307/13/162518g760971sqmq0zdm0.png)


现在你可以运行程序，以获得你所需的文字出现在动画中：



```
python3 PyBirthdayWish.py

```

### 使用自己的音乐文件


你可以使用自己的音乐文件作为这个动画的一部分。



> 
> ? 如果你计划在 YouTube 或其他网站上上传视频，请使用无版权的音乐以避免问题。
> 
> 
> 


将你的音乐文件复制到克隆的目录中。


![自定义的音乐文件被复制到克隆的目录中](/data/attachment/album/202307/13/162518i64qvqqv9scy9qm5.png)


编辑 `config.py` 文件以添加新的音乐，如下面的截图所示：


![在配置文件中添加自定义音乐文件以在动画中播放](/data/attachment/album/202307/13/162519eb04pfdx66zgfibb.png)


完成！现在，如果执行运行命令 `python3 PyBirthdayWish.py`，自定义音乐将与动画一起播放。


### 创建一个可执行文件


**如果你想将上述祝福消息作为可执行文件发送给朋友，这也是可行的。**


关联的 `pyinstaller` 将安装到 `.local/bin` 目录中，它不在你的路径中。


所以使用以下命令将该目录添加到你的路径中，[添加到你的路径中](https://itsfoss.com/add-directory-to-path-linux/)：



```
export PATH=$PATH:/home/team/.local/bin

```

要使其永久生效，将其添加到你的 `~/.bashrc` 文件中。


当你完成 art 文件的编辑并更改配置文件以反映更改后，使用以下命令创建一个可执行文件：



```
pyinstaller --noconfirm --onefile --console --icon "icon.ico" --no-embed-manifest --add-data "arts:arts/"  --add-data "config.py:." --add-data "HappyBirthday.mp3:." --add-data "PyBirthdayWish.py:."  "PyBirthdayWish.py"

```

它将在 `PyBirthdayWish/dist` 目录下创建一个名为 `PyBirthdayWish` 的可执行文件。


![程序创建的自定义可执行文件在文件管理器中显示](/data/attachment/album/202307/13/162520baszqvd0mfdiqqql.png)


将此可执行文件复制并发送给任何想查看它的人。他们可以使用以下命令执行它：



```
./PyBirthdayWish

```


> 
> ? 请始终谨慎运行来自未知外部来源的可执行文件。
> 
> 
> 


### 更多终端乐趣


像生日一样，圣诞节也是一个特殊的时刻。如果你愿意，你可以给你的 Linux 桌面增添一些节日气氛。



> 
> **[用 Linux 的方式庆祝圣诞节：为你的 Linux 系统增添圣诞气氛](https://itsfoss.com/christmas-linux-wallpaper/)**
> 
> 
> 


如果你喜欢 ASCII 动画，你可能也会喜欢 ASCII 艺术。



> 
> **[在 Linux 终端将图像转换为 ASCII 艺术图像](https://itsfoss.com/ascii-image-converter/)**
> 
> 
> 


为什么就止步于此呢？探索更多 ASCII 工具吧。



> 
> **[在 Linux 终端生成 ASCII 艺术并从中获得乐趣的 10 个工具](https://itsfoss.com/ascii-art-linux-terminal/)**
> 
> 
> 


享受以这种有趣的方式使用 Linux ?


? 如果你在使用这个工具时遇到任何问题，请告诉我，我会尽力在我所能的范围内提供帮助。


*（题图：MJ/dfa0185d-e9f9-4c1a-886e-e42c9bb8d687）*




---


via: <https://itsfoss.com/birthday-wish-linux-terminal/>


作者：[Sreenath](https://itsfoss.com/author/sreenath/) 选题：[lkxed](https://github.com/lkxed/) 译者：ChatGPT 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

Birthdays are special occasions, and it’s very satisfying and a pleasure to get birthday wishes from loved ones.

As a Linux user, you can surprise our friends and family with some cool birthday wishes from the terminal.

Here's a birthday card (or should I say animation) I created for the birthday of Abhishek Sir.

Everyone in the team liked it so much that I was requested to do a tutorial on it. I am only glad to comply as it may help our readers :)

This tutorial requires editing config files in the terminal. Proficiency with Linux terminals and commands make it easier to follow this tutorial.

## Install PyBirthdayWish

PyBirthdayWish is a small Python program through which you can create beautiful terminal birthday wishes. With music too!

The program itself is not available in the default repositories of Ubuntu. You need to install it using Pip.

First, [install pip in Ubuntu](https://itsfoss.com/install-pip-ubuntu/), using the command below:

`sudo apt install python3-pip`


Once Pip is installed, you can clone the repo and install the program:

`git clone https://github.com/hemantapkh/PyBirthdayWish.git && cd PyBirthdayWish && pip install -r requirements.txt`


On their repo, you can check the `.requirements.txt`

file to know what are the requirements as mentioned in the above command.

After the installation is complete, inside the `PyBirthdayWish`

directory, that you have cloned, run the command below:

`python3 PyBirthdayWish.py`


This will ask you to press F11 and then enter to go full screen mode and then play the animation.

![](https://itsfoss.com/content/images/2023/07/animation-page-1.png)

![](https://itsfoss.com/content/images/2023/07/animation-page-2.png)

Birthday Wish Animation in Terminal

There is music too, but not shown here.

It's highly customizable. **Let me show various levels of optional customization you can do with this tool.**

## Create the default birthday wish

In the above program, there are three wish Python files that can be used for the animation. They are, * example *(default),

*and*

`art`

*. You can open these three files in text editor to get an overview.*

`artwithstars`

![Contents of the arts directory, which has the default and user created art files](https://itsfoss.com/content/images/2023/07/arts-directory-contents.png)

Now, if you want to use the * artwithstars* file instead of the default example, open the

*in*

`config.py`

[any available text editor](https://itsfoss.com/command-line-text-editors-linux/), replace the

*entry with the required name and save it, as shown in the screenshot below:*

`arts`

![Change the animation design file to "art with stars" on the config file](https://itsfoss.com/content/images/2023/07/add-art-with-stars.png)

After that, in the `PyBirthdayWish`

directory, run:

`python3 PyBirthdayWish.py`


And you will get the new animation.

## Create a custom birthday wish

What if you want to print the name of your loved one, instead of the default text? This needs a little bit of patience because you need to edit the art file without destroying it.

First, make a backup copy of the design art files you want. Which is basically copying the file in the same `arts`

directory but with a different name; say `friend.py`

.

Now, open the design art file with the text editor of your choice. Replace the text in the art file with the one you need. It will be wise to use the symbols `| _ \ /`

for creating the text, design etc. You can use an [online tool to convert text to ASCII](https://patorjk.com/software/taag/#p=display&f=Big&t=Friend).

![Copied one of the existing design files and added a new text "Friend"](https://itsfoss.com/content/images/2023/07/new-text-added-to-art-file-friend.png)

Typing one character moves the rest of the animation one character forward. Similarly, removing a character moves the rest of the design, one character backward. So, you should add a space if you remove a character. Similarly, remove one space if you added a new character on a particular line. This should be done in real-time so that you can view the changes. This way, you can match the rest of the design and not destroy the looks, when completed.

After completing the edit, save it. Now, open *config.py* and change the art file to show your file.

![Change the design file in the config to reflext the changes we have done](https://itsfoss.com/content/images/2023/07/edit-config-file-to-add-custom-py-file.png)

You can now run to get your required text inside the animation:

`python3 PyBirthdayWish.py`


## Use your own music file

You can use your own music file as part of this animation.

If you are planning to upload the video on YouTube of other such sites, please use copyright-free music to avoid issues.

Copy your music file inside the cloned directory.

![Custome music file is copied inside the cloned directory](https://itsfoss.com/content/images/2023/07/showing-mymusic-file-in-directory.png)

Edit the *config.py* file to add the new music, as shown in the screenshot below:

![Adding the custom music file to the config file to play it during animation](https://itsfoss.com/content/images/2023/07/custom-music-file.png)

Done! Now, if you execute the run command, `python3 PyBirthdayWish.py`

, the custom music will be played along with the animation.

![](https://itsfoss.com/content/images/2023/04/efficient-at-linux-command-line-horizontal.png)

#### New Book: Efficient Linux at the Command Line

Pretty amazing Linux book with lots of practical tips. It fills in the gap, even for experienced Linux users. Must have in your collection.

[Get it from Amazon](https://amzn.to/3MPjiHw)

## Create an executable

**If you want to send the above wish message as an executable to a friend, there is a way for this too. **

An associated pyinstaller will be installed to the `.local/bin`

directory, which will not be on your path.

So [add that directory to your path](https://itsfoss.com/add-directory-to-path-linux/) using:

`export PATH=$PATH:/home/team/.local/bin`


To make it permanent, add it to your `~/.bashrc`

file.

After you are done with the art file editing and changing the config file to reflect the change, use the command below to create an executable:

`pyinstaller --noconfirm --onefile --console --icon "icon.ico" --no-embed-manifest --add-data "arts:arts/" --add-data "config.py:." --add-data "HappyBirthday.mp3:." --add-data "PyBirthdayWish.py:." "PyBirthdayWish.py"`


It will create an executable file named “PyBirthdayWish” to the `PyBirthdayWish/dist`

directory.

![The custome executable file created by the program, showed in file manager](https://itsfoss.com/content/images/2023/07/PyBirthdayWish-executable-location.png)

Copy this executable and send to anybody who want to view this. They can execute it with:

`./PyBirthdayWish`


Always be cautious while running executables from unknown external sources.

## More terminal fun

Like Birthdays, Christmas too is a special occasion. You can give some festive touch to your Linux desktop if you want.

[Celebrate Christmas in Linux Way: Give Your Linux System a Christmas TouchIt’s the holiday season and many of you might be celebrating Christmas already. From the team of It’s FOSS, I would like to wish you a Merry Christmas and a happy new year. To continue the festive mood, I’ll show you some really awesome Linux wallpapers on](https://itsfoss.com/christmas-linux-wallpaper/)![](https://itsfoss.com/content/images/wordpress/2016/12/linux-christmas-makeover.png)


![](https://itsfoss.com/content/images/wordpress/2016/12/linux-christmas-makeover.png)

If you liked ASCII animation, you may like ASCII art, too.

[Convert Images to ASCII Art in Linux TerminalWant some fun in the Linux terminal? How about converting a regular image into ASCII art? This tool lets you convert any image into ASCII art.](https://itsfoss.com/ascii-image-converter/)![](https://itsfoss.com/content/images/wordpress/2021/05/convert-ascii-image-linux.png)


![](https://itsfoss.com/content/images/wordpress/2021/05/convert-ascii-image-linux.png)

And why just stop here? Explore more ASCII tools.

[10 Tools to Generate and Have Fun With ASCII Art in Linux TerminalLinux terminal is not as scary as you think. Of course, it could be intimidating in the beginning but once you know the terminal better, you start loving it. You are likely to use the terminal for serious work. But there are many fun stuff you can do in the](https://itsfoss.com/ascii-art-linux-terminal/)![](https://itsfoss.com/content/images/wordpress/2022/07/ascii-art-tools-linux.png)


![](https://itsfoss.com/content/images/wordpress/2022/07/ascii-art-tools-linux.png)

Enjoy using Linux in this fun way :)

*🗨 Let me know if you face any issues with this tool and I'll try to help in my capacity.*