Saturday, November 21, 2020

How to force yourself to leave the computer using the leave command

Published at
Updated at
Reading time
2min

This post is part of my Today I learned series in which I share all my learnings regarding web development.

While browsing a collection of shell one-liners, I found out about a command that I haven't seen before: leave.

The command is straightforward. Run it and define an absolute or relative time, and your terminal will remind you to leave it alone and go at a certain time.

# set the alarm for 2:10pm
$ leave 1410
Alarm set for Fri Nov 20 14:10:00 CET 2020. (pid 3121)

# set the alarm in two minutes
$ leave +2

# set the alarm in two minutes interactively
$ leave
When do you have to leave? +2
Alarm set for Fri Nov 20 09:05:21 CET 2020. (pid 50717)

When the time arrives, the command running in the background sends shell notifications and prints new lines telling you to go. And let me tell you the best part: it doesn't do that once; it does that repeatedly every minute after the set alarm time. It will try hard to make you leave!

You can only stop the running leave process from annoying you by logging out of your shell session (or manually stopping the process). 😆

I love that! Maybe I should define leave 1900 in my .zshrc to force me to stop doing nerdy things late at night.

Edited: For the adventurous folks – Frederic Hemberger pointed out that you could also just shut down the system at a specific time using sudo shutdown -h 12:00 "Feierabend!". But be careful with this command; it could lead to data loss. 😆

Related Topics

Related Articles



from Hacker News https://ift.tt/3lPHpoW

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.