Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A shell script to display SEE YOU SPACE COWBOY whenever you logout of your terminal!
#!/usr/bin/env bash
# SEE YOU SPACE COWBOY by D.K. REHN (softdetours.com)
# Displays a timeless message in your terminal with cosmic color effects
# Usage: add "sh ~/seeyouspacecowboy.sh; sleep 2" to .bash_logout (or similar) in your home directory
# (adjust the sleep variable to display the message for more seconds)
# Cosmic color sequence
ESC_SEQ="\x1b[38;5;"
COL_01=$ESC_SEQ"160;01m"
COL_02=$ESC_SEQ"196;01m"
COL_03=$ESC_SEQ"202;01m"
COL_04=$ESC_SEQ"208;01m"
COL_05=$ESC_SEQ"214;01m"
COL_06=$ESC_SEQ"220;01m"
COL_07=$ESC_SEQ"226;01m"
COL_08=$ESC_SEQ"190;01m"
COL_09=$ESC_SEQ"154;01m"
COL_10=$ESC_SEQ"118;01m"
COL_11=$ESC_SEQ"046;01m"
COL_12=$ESC_SEQ"047;01m"
COL_13=$ESC_SEQ"048;01m"
COL_14=$ESC_SEQ"049;01m"
COL_15=$ESC_SEQ"051;01m"
COL_16=$ESC_SEQ"039;01m"
COL_17=$ESC_SEQ"027;01m"
COL_18=$ESC_SEQ"021;01m"
COL_19=$ESC_SEQ"021;01m"
COL_20=$ESC_SEQ"057;01m"
COL_21=$ESC_SEQ"093;01m"
RESET="\033[m"
# Timeless message
printf "$COL_01 .d8888b. 8888888888 8888888888 Y88b d88P .d88888b. 888 888 \n"
printf "$COL_02 d88P Y88b 888 888 Y88b d88P d88P\" \"Y88b 888 888 \n"
printf "$COL_03 \"Y888b. 8888888 8888888 Y888P 888 888 888 888 \n"
printf "$COL_04 \"Y88b. 888 888 888 888 888 888 888 \n"
printf "$COL_05 \"888 888 888 888 888 888 888 888 \n"
printf "$COL_06 Y88b d88P 888 888 888 Y88b. .d88P Y88b. .d88P \n"
printf "$COL_07 \"Y8888P\" 8888888888 8888888888 888 \"Y88888P\" \"Y88888P\" \n"
printf "$COL_08 .d8888b. 8888888b. d8888 .d8888b. 8888888888 \n"
printf "$COL_09 d88P Y88b 888 Y88b d88888 d88P Y88b 888 \n"
printf "$COL_10 \"Y888b. 888 d88P d88P 888 888 8888888 \n"
printf "$COL_11 \"Y88b. 8888888P\" d88P 888 888 888 \n"
printf "$COL_12 \"888 888 d88P 888 888 888 888 \n"
printf "$COL_13 Y88b d88P 888 d8888888888 Y88b d88P 888 \n"
printf "$COL_14 \"Y8888P\" 888 d88P 888 \"Y8888P\" 8888888888 \n"
printf "$COL_15 .d8888b. .d88888b. 888 888 888888b. .d88888b. Y88b d88P \n"
printf "$COL_16 d88P Y88b d88P\" \"Y88b 888 o 888 888 \"88b d88P\" \"Y88b Y88b d88P \n"
printf "$COL_17 888 888 888 888 d888b 888 8888888K. 888 888 Y888P \n"
printf "$COL_18 888 888 888 888d88888b888 888 \"Y88b 888 888 888 \n"
printf "$COL_19 888 888 888 888 88888P Y88888 888 888 888 888 888 \n"
printf "$COL_20 Y88b d88P Y88b. .d88P 8888P Y8888 888 d88P Y88b. .d88P 888 \n"
printf "$COL_21 \"Y8888P\" \"Y88888P\" 888P Y888 8888888P\" \"Y88888P\" 888\n"
printf "$RESET" # Reset colors to "normal"
@DeMarko

This comment has been minimized.

Copy link

DeMarko commented Jul 7, 2014

enable interpretation of backslash escapes with echo -e instead of echo

@DeMarko

This comment has been minimized.

Copy link

DeMarko commented Jul 7, 2014

#!/usr/bin/env bash is also more portable than #!/bin/bash

@nitish-nayak

This comment has been minimized.

Copy link

nitish-nayak commented Jul 7, 2014

Hi,

Also need to add to ~/.bashrc on an interactive non-login shell:

trap_exit() {
    . "$HOME/.bash_logout"
}
trap trap_exit EXIT
@softdetours

This comment has been minimized.

Copy link
Owner Author

softdetours commented Jul 7, 2014

@DeMarko: Great! I swapped in the more portable version of bash and replaced echo with printf as it's much more portable (echo -e is required in some environments, but prints the -e in other environments where it isn't required).

@kirbysayshi

This comment has been minimized.

Copy link

kirbysayshi commented Jul 8, 2014

I added this to my shell using an alias:

alias exit='sh ~/dotfiles/see-you.sh; sleep 2; exit'

Seems to work well!

@decal

This comment has been minimized.

Copy link

decal commented Jul 8, 2014

Instead of tput sgr0 you could have used an ANSI escape code to reset terminal color: echo -e '\033[m'
..but why not just use tput for the whole thing? Aren't the color gradients fine-grained enough? http://en.wikipedia.org/wiki/Tput#Usage http://dotfiles.org

@softdetours

This comment has been minimized.

Copy link
Owner Author

softdetours commented Jul 9, 2014

@decal: Thank you for the feedback! tput wouldn't work because of palette limitations, but I've tidied the final reset as an escape code for consistency.

@softdetours

This comment has been minimized.

Copy link
Owner Author

softdetours commented Jul 9, 2014

ATTN Windows people, Twitter user @randal_hicks has ported this script for Windows PowerShell: http://poshcode.org/5289

@seanlinsley

This comment has been minimized.

Copy link

seanlinsley commented Jul 19, 2014

For some reason the ANSI escape sequences wouldn't work for me (a Mac SSH-ing into an Ubuntu machine):

$ exit
logout
\x1b[38;5;160;01m  .d8888b.  8888888888 8888888888      Y88b   d88P  .d88888b.  888     888  
\x1b[38;5;196;01m d88P  Y88b 888        888              Y88b d88P  d88P" "Y88b 888     888  
\x1b[38;5;202;01m  "Y888b.   8888888    8888888            Y888P    888     888 888     888  
\x1b[38;5;208;01m     "Y88b. 888        888                 888     888     888 888     888  
\x1b[38;5;214;01m       "888 888        888                 888     888     888 888     888  
\x1b[38;5;220;01m Y88b  d88P 888        888                 888     Y88b. .d88P Y88b. .d88P  
\x1b[38;5;226;01m  "Y8888P"  8888888888 8888888888          888      "Y88888P"   "Y88888P"  
\x1b[38;5;190;01m  .d8888b.  8888888b.     d8888  .d8888b.  8888888888    
\x1b[38;5;154;01m d88P  Y88b 888   Y88b   d88888 d88P  Y88b 888       
\x1b[38;5;118;01m  "Y888b.   888   d88P d88P 888 888        8888888    
\x1b[38;5;046;01m     "Y88b. 8888888P" d88P  888 888        888   
\x1b[38;5;047;01m       "888 888      d88P   888 888    888 888    
\x1b[38;5;048;01m Y88b  d88P 888     d8888888888 Y88b  d88P 888  
\x1b[38;5;049;01m  "Y8888P"  888    d88P     888  "Y8888P"  8888888888     
\x1b[38;5;051;01m  .d8888b.   .d88888b.  888       888 888888b.    .d88888b. Y88b   d88P     
\x1b[38;5;039;01m d88P  Y88b d88P" "Y88b 888   o   888 888  "88b  d88P" "Y88b Y88b d88P   
\x1b[38;5;027;01m 888        888     888 888 d888b 888 8888888K.  888     888   Y888P    
\x1b[38;5;021;01m 888        888     888 888d88888b888 888  "Y88b 888     888    888    
\x1b[38;5;021;01m 888    888 888     888 88888P Y88888 888    888 888     888    888  
\x1b[38;5;057;01m Y88b  d88P Y88b. .d88P 8888P   Y8888 888   d88P Y88b. .d88P    888  
\x1b[38;5;093;01m  "Y8888P"   "Y88888P"  888P     Y888 8888888P"   "Y88888P"     888

Though they'd otherwise work if I ran this file directly :-/

So I rewrote this in Ruby, since for some bizarre reason it worked fine from .bash_logout

#!/usr/bin/env ruby

# SEE YOU SPACE COWBOY by DANIEL REHN (danielrehn.com)
# Displays a timeless message in your terminal with cosmic color effects

# Usage: add 'ruby ~/seeyouspacecowboy.rb; sleep 2" to .bash_logout (or similar) in your home directory
# (adjust the sleep variable to display the message for more seconds)

class String
  def colorize(color_code)
    "\e[#{color_code}m#{self}\e[0m"
  end
end

puts '  .d8888b.  8888888888 8888888888      Y88b   d88P  .d88888b.  888     888 '.colorize '38;5;160;01'
puts ' d88P  Y88b 888        888              Y88b d88P  d88P" "Y88b 888     888 '.colorize '38;5;196;01'
puts '  "Y888b.   8888888    8888888            Y888P    888     888 888     888 '.colorize '38;5;202;01'
puts '     "Y88b. 888        888                 888     888     888 888     888 '.colorize '38;5;208;01'
puts '       "888 888        888                 888     888     888 888     888 '.colorize '38;5;214;01'
puts ' Y88b  d88P 888        888                 888     Y88b. .d88P Y88b. .d88P '.colorize '38;5;220;01'
puts '  "Y8888P"  8888888888 8888888888          888      "Y88888P"   "Y88888P"  '.colorize '38;5;226;01'
puts '  .d8888b.  8888888b.     d8888  .d8888b.  8888888888                      '.colorize '38;5;190;01'
puts ' d88P  Y88b 888   Y88b   d88888 d88P  Y88b 888                             '.colorize '38;5;154;01'
puts '  "Y888b.   888   d88P d88P 888 888        8888888                         '.colorize '38;5;118;01'
puts '     "Y88b. 8888888P" d88P  888 888        888                             '.colorize '38;5;046;01'
puts '       "888 888      d88P   888 888    888 888                             '.colorize '38;5;047;01'
puts ' Y88b  d88P 888     d8888888888 Y88b  d88P 888                             '.colorize '38;5;048;01'
puts '  "Y8888P"  888    d88P     888  "Y8888P"  8888888888                      '.colorize '38;5;049;01'
puts '  .d8888b.   .d88888b.  888       888 888888b.    .d88888b. Y88b   d88P    '.colorize '38;5;051;01'
puts ' d88P  Y88b d88P" "Y88b 888   o   888 888  "88b  d88P" "Y88b Y88b d88P     '.colorize '38;5;039;01'
puts ' 888        888     888 888 d888b 888 8888888K.  888     888   Y888P       '.colorize '38;5;027;01'
puts ' 888        888     888 888d88888b888 888  "Y88b 888     888    888        '.colorize '38;5;021;01'
puts ' 888    888 888     888 88888P Y88888 888    888 888     888    888        '.colorize '38;5;021;01'
puts ' Y88b  d88P Y88b. .d88P 8888P   Y8888 888   d88P Y88b. .d88P    888        '.colorize '38;5;057;01'
puts '  "Y8888P"   "Y88888P"  888P     Y888 8888888P"   "Y88888P"     888        '.colorize '38;5;093;01'

Cheers 🍻

Edit: I made a fork for easy copying if this helps anyone else: https://gist.github.com/seanlinsley/3e49c09dcdfc37f05eb4

@monokal

This comment has been minimized.

@babylon-engineer

This comment has been minimized.

Copy link

babylon-engineer commented Mar 9, 2015

hey, sorry im so new to this but i was wondering if anyone could help me use this?
ive tried quite a few times to make this work and had no luck. ive even tried to enable root and had no luck.
any suggestions?

@nawb

This comment has been minimized.

Copy link

nawb commented Mar 22, 2015

@babylon-engineer, you have to enable your terminal as a login shell in preferences.
But if that still doesn't display the colors (since it performs the logout command before executing .bash_logout), then try kirbysayshi's method above. In .bash_rc,

alias exit='sh ~/dotfiles/seeyouspacecowboy.sh; sleep 2; exit'
@flanger001

This comment has been minimized.

Copy link

flanger001 commented Dec 13, 2015

@seanlinsley Thanks for the Ruby script!

@doekman

This comment has been minimized.

Copy link

doekman commented Jul 19, 2016

Did anyone combine Text to ASCII Art Generator with lolcat?

edit: Meh. I like space cowboy colors better than lolcat.

@si-rbrisita

This comment has been minimized.

Copy link

si-rbrisita commented Jul 19, 2016

Awesome! Thanks for this! @kirbysayshi alias in the .bash_profile file on Mac OS X works beautifully.

@mattpolicastro

This comment has been minimized.

Copy link

mattpolicastro commented Sep 13, 2016

@seanlinsley, switching out the sh for . or source appears to resolve the problem on Ubuntu. Trying to figure out why here.

@dwo

This comment has been minimized.

Copy link

dwo commented May 25, 2019

As mentioned in the SO answers linked above, bash ~/seeyouspacecowboy.sh; sleep 2 (instead of sh) fixes the colour issue on macs shelling to debian-like systems. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.