Emoji Command Prompt ๐Ÿ’ป

October 9, 2021 ยท View on GitHub

Kapture 2021-08-30 at 20 10 05

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 Screenshot 2021-08-30 at 21 33 31 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. Kapture 2021-08-30 at 22 05 28

The following is dinner-time highighted emoji with psanimate .2 Kapture 2021-08-30 at 21 58 12

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. Kapture 2021-09-03 at 12 29 52

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 ๐Ÿ™

๐ŸŽซ License

MIT ยฉ bigomega