Skip to content

Instantly share code, notes, and snippets.

@relsqui
Created February 20, 2017 07:28
Show Gist options
  • Save relsqui/0ab32bea930c5ea04219df0e4fde0669 to your computer and use it in GitHub Desktop.
Save relsqui/0ab32bea930c5ea04219df0e4fde0669 to your computer and use it in GitHub Desktop.
Animated ASCII art fish for your screenrc.
Copyright 2017 Finn Ellis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#!/usr/bin/python3
"""
Screenfish: An ASCII fish friend to hang out in your screen session.
(c) 2017 Finn Ellis. Free to use under the MIT license.
To make this work, you'll need screenfish in your $PATH and the following
lines in your .screenrc, replacing N with some backtick id that's not in use
(if you don't have any backtick lines in your .screenrc yet, that can be 1).
backtick N 1 1 screenfish
caption always '%= %N` %='
Feel free to adjust the WIDTH below too, to resize your fishtank.
Or the LFISH/RFISH art if your terminal doesn't support Unicode.
Note that this will conflict with any other caption line you have set, but if
you're the sort of person to already have a caption line set in your
.screenrc, you probably guessed that.
"""
import datetime
RFISH="><ε*>"
LFISH="<*3><"
WIDTH=80 - len(RFISH)
def tri_wave(x, period=8):
y = x % period - period/2
if y < 0:
asc = False
else:
asc = True
return int(abs(y)), asc
def fish(forward):
if forward:
return RFISH
else:
return LFISH
def pad(count):
return " " * count
spaces, forward = tri_wave(int(datetime.datetime.now().timestamp()), WIDTH)
print(pad(spaces) + fish(forward) + pad(WIDTH-spaces))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment