Emoji Command Prompt ๐ป
October 9, 2021 ยท View on GitHub

Blog post
Table of Contents
:package: Installation
# Clone the repo
git clone git@github.com:bigomega/emoji-ps1.git
cd emoji-ps1
cd-ing into the repo is inmportant because we'll be using $PWD
With OhMyZsh
This is written on top of the robbyrussell (default) theme.
# Link it to the custom themes folder
ln $PWD/emoji.js $HOME/.oh-my-zsh/custom/themes/emoji.js
ln $PWD/emoji.zsh-theme $HOME/.oh-my-zsh/custom/themes/emoji.zsh-theme
Set the theme in ~/.zshrc file
ZSH_THEME="emoji"
Without OhMyZsh
For a simple version
# Prepending emoji to the current PS1
echo "\n#Emoji PS1\nPS1=\"\\\$(node $PWD/emoji.js) \"\$PS1" >> ~/.bashrc
source ~/.bashrc
For animations, copy the psanimate and psanimate_stop functions from the /emoji.zsh-theme file to ~/.bashrc
If you face issues with node, install/update node to the latest stable version. This was developed on
v16.6.0
:drum: Features & Customization :hammer_and_wrench:
:spiral_calendar: Schedule
The emoji.js file contains the logic behind the what emoji to show and when.
There's a Schedule for the emoji which you can/should change in JS here.
const timings = [
// from, duration, emoji, highlight?, unstoppable?
[0, 500, '๐', true, true],
[530, 200, getRandom(activity_list)],
[800, 200, '๐ฅช', true],
[1300, 130, '๐', true],
...
The highlight flag shows an arrow โฌ
after the emoji
The unstoppable flag says that the scheduled emoji cannot be overridden by
You can/should edit these two lists as well depending your interests, likes and visually appealing emojis.
const fun_list = "๐พ,๐,๐ฅ,โฐ๏ธ ,๐ช,๐บ,๐จ๐ปโ๐พ,๐ข,๐ผ,๐,๐ณ,๐,๐ชต ,๐,๐ฅ,๐ช ,๐,๐,๐,๐,๐ฅ,๐".split(',')
const activity_list = '๐จ,๐ฆฎ,๐,โ๏ธ ,๐ธ,๐น,๐๐ปโโ๏ธ'.split(',')
๐ฎ Animation
All of these could be animated. You can start the animation with the command (bash function) psanimate <interval-in-seconds>, defaults to 1 second. Animate calls the emoji function in the given interval with a rotating SWITCH boolean.

The following is dinner-time highighted emoji with psanimate .2

Animation runs as a background process, stores the pid in
/tmp/psanimatepid-$$.
๐ฆพ Automating animations
This is disabled by default since automated animations could be very much annoying. But you can enable it by setting the PS_AUTO_ANIMATE variable. The schedule and check-interval is in the function right below the variable. By default it checks every 30 minutes and animates during sleep time.
PS_AUTO_ANIMATE=1
โ Finishing tasks
Certain activity emojis like food can be overridden (when it's over). This can be done with the command pstaskover. This sets the env variable PS_TASK_OVER and so an emoji from the fun_list is picked up after.

The PS_TASK_OVER resets after an hour. It uses bash traps.
๐ป Contribution & Request
If you find this idea interesting or if you can imagine beautiful ideas, please send a PR or raise a request for it. Thanks ๐