cowsay
Cowsay is a configurable command-line program that generates ASCII art pictures of a cow with a speech bubble containing a user-provided message, often used to add humor to terminal output on Unix-like systems.[1] It functions as a text filter, accepting input from standard input or command-line arguments, and can be paired with tools like figlet to render the message in stylized text.[2]
Originally developed in Perl by Tony Monroe, cowsay draws inspiration from the cow-themed culture of the Computer Science Undergraduate Association (CSUA) at the University of California, Berkeley, where simple ASCII cows were a longstanding meme.[2] Monroe first released the program in 1999, with early versions enhancing basic cow art by adding expressive features like "thinking" poses via the companion tool cowthink.[3] The software requires Perl 5 and includes customizable "cowfiles" for different animals or characters, such as tux (a penguin) or dragon, allowing users to select from dozens of predefined templates.[4]
After Monroe's final release (version 3.04), the project saw limited maintenance until 2016, when Andrew Janke forked it to address bugs and improve compatibility, leading to the current cowsay-org repository under the GNU General Public License version 3.[3] This fork, now at version 3.8.4, supports modern systems and has inspired ports in languages like Python, JavaScript, and R, preserving cowsay's whimsical utility in developer workflows.[4] Despite its silliness, cowsay remains a cultural staple in open-source communities, symbolizing the playful side of command-line computing.[5]
History
Origins and Development
Cowsay was originally developed by Tony Monroe, a software developer active in the Unix and open-source communities, as a lightweight Perl script designed to inject humor into command-line interfaces. Released in 1999, the program generates ASCII art of a cow (or other figures) delivering user-specified messages in speech bubbles, serving as a configurable novelty tool. Cowsay was inspired by simple ASCII cows that were a longstanding meme in the Computer Science Undergraduate Association (CSUA) at the University of California, Berkeley, with suggestions from Shannon Appel and contributions from Anthony Polito.[5]
Monroe's creation emerged from the vibrant Perl scripting culture of the late 1990s, a period when Perl dominated as the go-to language for quick, expressive scripts on Unix-like systems, often used for CGI web applications, system automation, and whimsical utilities that enhanced developer workflows. Written entirely in Perl, cowsay exemplified this culture's emphasis on practicality blended with fun, allowing users to customize outputs for comic relief during scripting sessions or log reviews. The initial version operated under the Artistic License, Perl's default permissive license, which was later supplemented with dual licensing under the GNU General Public License to broaden compatibility with free software distributions.[6]
Early distribution occurred primarily through Monroe's personal website, where the source code and binaries were made available for download, fostering grassroots adoption among Linux and BSD users. By the early 2000s, cowsay had gained enough popularity to be packaged and included in major Linux distributions, such as Debian, marking its transition from a personal project to a standard utility in open-source ecosystems. This organic spread highlighted its appeal as a simple yet endearing addition to the toolkit of programmers seeking to humanize (or bovine-ize) their terminal experiences.[4][7]
Key Releases and Maintenance
Cowsay was first publicly released in 1999 by its original author, Tony Monroe, with early versions featuring basic functionality such as a single cow ASCII art and simple message templates.[4] Subsequent development led to version 2, which introduced support for arbitrary messages, multiple cow files, and integration with figlet for banner text generation.[4] By version 3.0, the program underwent a complete rewrite in Perl 5, resulting in more compact and maintainable code while enhancing overall features like improved modularity.[4]
The original project reached its final release under Monroe with version 3.04 in 2016, after which maintenance ceased.[8] In 2016, Andrew Janke created an active fork to address ongoing needs, including bug fixes and compatibility improvements for modern systems; this fork, hosted at github.com/cowsay-org/cowsay, became the primary source for distributions like Homebrew.[4] The latest stable release as of November 2025 is version 3.8.4, released on December 1, 2024, which includes updates for Perl compatibility and minor fixes to ensure reliability on contemporary Unix-like environments.
Licensing for cowsay has evolved to align with Perl's terms, initially distributed under the Artistic License.[9] Later versions incorporated dual licensing with the GNU General Public License version 2 or later (GPL v2+), providing greater compatibility for redistribution and integration in various software ecosystems.[10] New contributions since the fork are explicitly dual-licensed under GPL v1+ or Artistic License 1.0 to encourage community involvement.[4]
Functionality
Core Mechanism
The cowsay program, implemented as a Perl script, reads input text either from standard input when invoked without arguments or directly from command-line arguments provided by the user.[11] It processes this input by word-wrapping the text to a default width of 40 characters to fit the output layout, preserving the message's readability within the ASCII constraints; this wrapping can be disabled to maintain original whitespace but is essential for standard operation.[11]
The wrapped text is then formatted into an ASCII art bubble: a speech bubble positioned to the side of the animal for the cowsay command, or a thought bubble placed above the animal for the cowthink variant, with the latter using a trail defined in the template file.[11] This differentiation allows cowsay to simulate spoken messages emerging from the animal's mouth area, while cowthink evokes internal monologue emerging from the head.[11]
Animal rendering relies on template files with the .cow extension, which contain Perl code executed by the program to define the core ASCII art structure.[11] These files assign a multi-line string to the the_cow variable for the animal's body, along with optional variables such as eyes (defaulting to "oo"), tongue (defaulting to a space), and thoughts for the bubble connector; the program overlays the message bubble onto this rendered figure, typically aligning it to the right side relative to the animal's orientation.[11] The entire output is generated as plain text and directed to standard output, enabling seamless piping to other commands without any graphical dependencies.[11]
Command-Line Parameters
Cowsay provides a range of command-line parameters to customize the output, including selections for animal files, message formatting, and modifications to the ASCII art's expressions and features. These options allow users to tailor the cow's appearance and the speech balloon's style without editing the underlying cow files. The parameters are processed from left to right, with any remaining arguments treated as the message text or read from standard input if none are provided.[12]
Core options enable basic configuration of the animal and message layout. The -f <file> parameter specifies a particular cow picture file from the available .cow files, such as -f dragon to use a dragon that includes fire breath in its ASCII art.[13] The -l option lists all defined cow files available on the current COWPATH. The -W <width> parameter sets the column width for word-wrapping the message, defaulting to 40 columns if unspecified.[11]
Expression controls alter the cow's facial features to convey different moods through predefined eye and tongue changes. The -b option invokes Borg mode, producing a cow resembling a Borg drone with adjusted eyes. The -d option sets dead eyes, making the cow appear lifeless. The -g option enables greedy mode, changing the eyes to look avaricious. The -s option creates a stoned appearance with droopy eyes and a tongue. The -t option yields a tired cow with half-closed eyes. The -y option displays a youthful cow with wide, innocent eyes.[13]
Additional parameters modify the balloon, wrapping behavior, and other elements. The -n option disables word-wrapping, allowing the full message to display without breaks, which is useful for embedding other ASCII art. The -p option induces paranoia mode, altering the cow's expression to look suspicious.[12] The -T <tongue> parameter specifies a custom two-character tongue string, overriding defaults like the "U" in stoned mode. Using -f dragon also activates a special mode where the dragon exhales fire in the artwork.[12]
Utility flags provide direct customization and information. The -e <eyes> option sets the cow's eyes using a two-character string, defaulting to "oo" for normal wide eyes; for example, -e XX produces dead eyes. The -v option displays version information about the cowsay installation. These options can be combined, such as with the fortune command for random messages, but detailed integrations are covered elsewhere.[14]
Usage Examples
Basic Output Examples
The basic output of cowsay demonstrates its core functionality by generating an ASCII art cow with a speech bubble containing the provided message, using the default cow design from the default.cow file. When invoked with a short message like cowsay "Hello, world!", the program produces a simple speech bubble above the cow, with the text centered and padded within the bubble's width.[11][14]
_____________
< Hello, world! >
-------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_____________
< Hello, world! >
-------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
The cowthink variant, invoked as cowthink "The cow is thinking.", modifies the output to use a thought bubble instead of a speech bubble, placing the message within rounded parentheses above the cow while retaining the default animal design. This illustrates the program's ability to differentiate between speaking and thinking modes through bubble styling.[11]
(The cow is thinking.)
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
(The cow is thinking.)
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
When no message is provided on the command line, cowsay reads input from standard input (stdin), automatically word-wrapping long lines at approximately 40 columns by default to fit the bubble. For example, piping a multi-line message via echo -e "This is the first line.\nThis is the second line." | cowsay preserves the newlines in the bubble, padding shorter lines with spaces to align with the longest line's width, resulting in a multi-line speech bubble. Similarly, a long single line input wraps across multiple bubble lines if it exceeds the wrap width.[11][15]
_____________________
< This is the first >
< line. >
< This is the second >
< line. >
---------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_____________________
< This is the first >
< line. >
< This is the second >
< line. >
---------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
To explore available built-in cow files beyond the default, the command cowsay -l lists the herd of ASCII art options installed in the system's cow directory, such as default, tux (a penguin), and milk (a milking cow), printed in a human-readable format for terminal use. This output helps users identify basic animal variants without customization.[14]
Cow files in /usr/share/cowsay/cows/:
apt beavis.zen bud-frogs bunny
cheese cock cow default
dragon elephant eyes flaming-sheep
ghostbusters head-in hellokitty kiss
kitty koala kosh luke-maul
mech-and-cow milk moofasa moose
mutilated pony ren sheep
skeleton small stegosaurus stimpy
superman surgery three-eyes turkey
turtle tux unipony unizoid
vader-koala vader www
Cow files in /usr/share/cowsay/cows/:
apt beavis.zen bud-frogs bunny
cheese cock cow default
dragon elephant eyes flaming-sheep
ghostbusters head-in hellokitty kiss
kitty koala kosh luke-maul
mech-and-cow milk moofasa moose
mutilated pony ren sheep
skeleton small stegosaurus stimpy
superman surgery three-eyes turkey
turtle tux unipony unizoid
vader-koala vader www
Customized and Multi-Animal Examples
Cowsay allows users to modify the cow's facial expression through dedicated options for eyes and tongue, enabling a range of emotional or whimsical depictions. The -e option sets the eyes using the first two characters of the provided string, overriding the default "oo" to create effects like surprised (^^) or squinted (--) expressions, while the -T option similarly configures the tongue with two characters, which only displays in modes where it is visible, such as dead or stoned.[12] Predefined modes further simplify variations: for example, the -b (Borg) mode uses "==" for eyes and "U" for tongue, and the -g (greedy) mode employs "$$" for eyes to suggest avarice.[12]
Combining these options yields hybrid expressions; the command cowsay -t -g "Tired and greedy" can result in a cow with greedy eyes ("$$", overriding tired "--") and default tongue (none), blending fatigue with material desire for humorous effect, though mode combinations may lead to overrides.[12] Similarly, direct customization like cowsay -e "xx" -T "\\|" "Exasperated outburst" produces crossed eyes and a clenched tongue (if visible in the mode), evoking frustration.[12]
Beyond the default cow, cowsay supports alternative animal templates via the -f option, which loads ASCII art from .cow files containing predefined shapes—these files define the body, eyes, and tongue positions for variety (as detailed in Built-in Cow Files).[12] For instance, cowsay -f tux "[Linux](/page/Linux) penguin speaks" displays Tux, the Linux mascot penguin, with a speech bubble, substituting the cow's form while retaining the messaging mechanism.[12] The dragon template adds dramatic flair: cowsay -f dragon "Fire-breathing message" renders a fiery dragon with integrated flame graphics in the ASCII art, enhancing the visual impact of warnings or exclamations.[12]
Multiple parameters can be layered for refined outputs, adjusting layout and style simultaneously. The command cowsay -f bunny -W 20 -p "Poncy rabbit balloon" uses the bunny template, narrows the speech bubble width to 20 columns with -W, and applies paranoid mode (-p) for "@@" eyes, creating a nervous, compact rabbit in a floating balloon-like bubble.[12] This combination is useful for space-constrained terminals or themed presentations.
If an invalid .cow file is specified with -f, cowsay terminates with an error message, such as "cowsay: Couldn't open cowfile `invalid.cow'", preventing execution and alerting users to check available files via the -l option.[12]
Variants and Implementations
Built-in Cow Files
The built-in cow files in cowsay consist of predefined ASCII art designs stored as .cow files within the program's original Perl distribution and its maintained forks. These files define various animals and figures that can be rendered alongside user messages, providing thematic variety to the output.[11][4]
Each .cow file is structured as a simple block of Perl code that assigns a multiline ASCII string to the variable $the_cow, which outlines the figure's body, head, legs, and other parts using placeholders for dynamic elements like eyes ($eyes), tongue ($tongue), and the thoughts or speech balloon trail ($thoughts). Backslashes, at signs, dollar signs, and certain other characters within the ASCII art must be escaped to ensure proper parsing by the Perl interpreter. This format allows for modular customization while maintaining compatibility across implementations.[11]
The default cow, defined in default.cow, portrays a basic four-legged bovine with straightforward circular eyes and an optional protruding tongue, embodying the program's core humorous aesthetic as a simple, anthropomorphic farm animal delivering the message.[11]
Among the themed built-in files, several draw from animals, mythical creatures, and cultural icons to expand creative options. For instance, tux.cow features the Linux mascot Tux as a plump penguin waddling on ice, dragon.cow depicts a fierce, fire-breathing dragon with wings and flames, bunny.cow shows a cute rabbit with long ears and a fluffy tail, milk.cow illustrates a cow in the midst of being milked with attached udder details, ghostbusters.cow renders a spectral, translucent ghost figure, sheep.cow presents a woolly sheep with curved horns, and bud-frogs.cow displays a pair of frogs perched together in a whimsical pose. These designs, contributed over time to the original project by Tony Monroe and community members, highlight diverse motifs from nature to pop culture.[16][4]
Modern forks and distributions of cowsay include approximately 50 built-in .cow files, an expansion from the smaller set in the initial Perl release, enabling users to select from a broader palette while supporting easy extension through additional user-supplied files placed in the cows directory.[4][16]
Ports and Forks in Other Languages
A Python port of cowsay, available as the cowsay package on PyPI since 2017, replicates the original Perl program's core functionality including ASCII art generation and command-line interface support, and can be installed via pip install cowsay.[5]
The JavaScript implementation by piuccio, hosted on GitHub since the early 2010s, translates the original Perl code to support Node.js environments and browser usage, with features like customizable eyes and tongue, and includes online demonstration capabilities through npm integration.[17]
In R, the cowsay package on CRAN, developed by Scott Chamberlain and first released in 2014, enables printing messages, warnings, or strings alongside ASCII animals within R sessions, facilitating fun integrations in data science workflows such as console outputs during analysis.[18][19]
Community forks extend the original, such as Andrew Janke's maintenance fork under the cowsay-org organization on GitHub, which adds pluggable third-party cow collections, and is distributed via Homebrew for macOS and Linux with brew install cowsay.[4][20]
Web-based adaptations include cowsay.morecode.org, a service providing an online interface and JSON API for generating cow messages via GET or POST requests with parameters for text and format, allowing programmatic access without local installation.[21]
Ports introduce extensions like additional animals; for instance, the R version includes over 50 creatures, such as alligators, bats, dragons, and yodas, stored as separate .cow files for easy expansion.
For Windows compatibility, cowsay runs via Cygwin, a POSIX emulation layer, where users can install it manually by extracting pre-built tarballs or compiling from source after setting up required Perl dependencies.[22]
Cultural Impact
Role in Hacker and Open-Source Culture
Cowsay emerged as a beloved tool in early 2000s hacker and open-source communities, gaining widespread attention through a feature article in the Linux Gazette issue #67 in June 2001, which described it as a configurable Perl program for generating humorous ASCII art in terminals.[23] This exposure helped solidify its place as a lighthearted addition to Unix-like systems, appealing to developers and enthusiasts who appreciated its simplicity and silliness amid more utilitarian software.
As a symbol of open-source whimsy, cowsay exemplifies lightweight scripting that injects fun into command-line workflows without compromising functionality; it has been packaged and distributed in prominent Linux distributions, including Ubuntu since at least 2004 and Fedora, making it readily available to millions of users worldwide.[24] The tool's inclusion in these repositories underscores its role in fostering a playful culture within open-source development, where such novelties contrast with the rigor of system administration and programming.
The open-source community has sustained cowsay's vitality through collaborative contributions, particularly by creating and sharing custom .cow files that define new animal or character appearances; these are hosted in dedicated repositories, such as collections of alternative cows on GitHub, allowing users to extend the program's creativity beyond its original 47 built-in files.[25] System administrators have further integrated cowsay into bash scripts for entertaining notifications, often piping outputs from commands like fortune or system queries to generate visually engaging messages in terminals.[26]
Modern Applications and Extensions
In contemporary scripting environments, cowsay remains a lightweight tool for enhancing terminal output through piping with utilities like fortune, which generates random quotes displayed via the cow's speech bubble, adding whimsy to shell sessions.[26] This integration, often automated in shell profiles such as .bashrc, provides dynamic, motivational messages upon terminal launch.[27] Additionally, cowsay appears in continuous integration and continuous deployment (CI/CD) pipelines, particularly in GitHub Actions workflows, where it visualizes build statuses or deployment confirmations in tutorial demonstrations, making abstract processes more engaging for learners and teams.[28]
Educationally, cowsay serves as an accessible entry point in programming tutorials and introductory Unix courses, illustrating concepts like standard input/output redirection and ASCII art generation without requiring complex syntax.[29] Instructors use it to demonstrate piping—such as combining it with system commands like ls or date—to create visually appealing outputs that reinforce command-line fundamentals, fostering interest among beginners in Linux environments.[30] Its simplicity allows integration into broader curricula on shell scripting, where students customize cow files to explore file handling and text manipulation.[26]
Web-based extensions have proliferated through JavaScript ports, enabling dynamic content generation in browsers without native terminal access. The npm cowsay package, a direct translation of the original Perl program, powers online tools that render cow ASCII art client-side for interactive web applications.[31] For instance, APIs like the Deno-based cowsay service on Vercel accept POST requests with text payloads, returning formatted art for embedding in web pages or real-time chat interfaces.[32] Dedicated generators, such as those at cowsay.morecode.org and cowsay-svelte.vercel.app, allow users to input messages and export results as text or images, extending cowsay's utility to non-terminal contexts like social media or documentation.[33]
As of 2025, cowsay integrates into containerized workflows via Docker images, such as grycap/cowsay, which combines it with fortune for automated, humorous outputs in deployment scripts or testing environments, simplifying fun additions to microservices.[34] Mobile adaptations further broaden accessibility, with apps on F-Droid, Google Play, and the App Store replicating the core functionality—generating customizable ASCII art from user text—for on-the-go sharing via screenshots or clipboard export.[35][36] These ports in languages like JavaScript, as detailed in prior implementations, facilitate such cross-platform extensions.[31]