Table of Contents
# 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
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"
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
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(',')
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-$$
.
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
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.
If you find this idea interesting or if you can imagine beautiful ideas, please send a PR or raise a request for it. Thanks 🙏