Awesome
Emoji Command Prompt 💻
Blog post
Table of Contents
- Emoji Command Prompt 💻
: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
<img src="https://user-images.githubusercontent.com/2320747/131363393-c2f28fdf-7675-49f2-bc8a-42b62936a877.png" width="20px"/> 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"
<img src="https://user-images.githubusercontent.com/2320747/131363393-c2f28fdf-7675-49f2-bc8a-42b62936a877.png" width="20px"/> 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
<img width="1123" alt="Screenshot 2021-08-30 at 21 33 31" src="https://user-images.githubusercontent.com/2320747/131369199-3f87ad67-dd0e-4726-a044-e472312ee157.png">
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 🙏