Skip to content

unixorn/warhol.plugin.zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

warhol.plugin.zsh

License GitHub stars GitHub last commit (branch) Megalinter Awesomebot

Table of Contents

warhol adds some color-related environment variables, functions and helper scripts to your environment.

Environment Variables

If LSCOLORS or LS_COLORS are not already set, warhol will set reasonable default values for them. If you want to customize them, Geoff Greer made an online tool that makes it easy to customize your color scheme and keep them in sync across Linux and macOS/*BSD at http://geoff.greer.fm/lscolors/

Unless WARHOL_NO_ANSIVARS is set, warhol will set the following variables for you so you can make your functions colorize their output more easily.

Modifiers

ANSI_RESET, ANSI_BOLD, ANSI_UNDERLINE, ANSI_FLASH and ANSI_INVERSE

Foreground Colors

ANSI_BLACK, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, ANSI_BLUE, ANSI_MAGENTA, ANSI_CYAN and ANSI_WHITE

Background Colors

ANSI_BG_BLACK, ANSI_BG_RED, ANSI_BG_GREEN, ANSI_BG_YELLOW, ANSI_BG_BLUE, ANSI_BG_MAGENTA, ANSI_BG_CYAN, ANSI_BG_WHITE

Commands Colorized

The plugin will look for the following commands, and if found, create a function that wraps them in grc to colorize their output.

blkid, cc, configure, curl, df, diff, dig, docker, docker-machine, du, env, fdisk, free, g++, gas, gcc, getsebool, head, id, ifconfig, iostat, ip, iptables, jobs, journalctl, kubectl, last, ld, ls, lsattr, lsblk, lsmod, lsof, lspci, make, mount, mtr, netstat, nmap, php, ping, ping6, ps, pv, semanage, stat, sysctl, systemctl, tail, tcpdump, traceroute, traceroute6, ulimit, uptime and vmstat.

If you don't want a command wrapped, set a variable named warhol_ignore_COMMANDNAME. To disable wrapping ls for example, set warhol_ignore_ls. The value doesn't matter, the plugin only checks for its existence.

  • Colorize command output using grc (when present) and lscolors.
  • Add colorize-tab, iterm-tab-color, tab-reset-color, tab-red, tab-green and tab-blue helper scripts to colorize Iterm 2 tabs.

Helper Scripts

Name Source Description
ansi http://github.com/fidian/ansi Can be called from scripts to colorize output, see ansi --help
colorize-tab jpb@unixorn.net Sets an iTerm2 tab to an rgb color with colorize-tab R G B
tab-blue jpb@unixorn.net Sets iTerm2 tab color to blue
tab-green jpb@unixorn.net Sets iTerm2 tab color to green
tab-red jpb@unixorn.net Sets iTerm2 tab color to red
tab-reset-color jpb@unixorn.net Resets the iTerm2 tab color back to default

Installing

Add zgenom load unixorn/warhol.plugin.zsh to your .zshrc with your other load commands.

Add antigen bundle unixorn/warhol.plugin.zsh to your .zshrc

If you're using oh-my-zsh:

  1. In the command line, change to oh-my-zsh's custom plugin directory :

    cd ~/.oh-my-zsh/custom/plugins/

  2. Clone the repository into a new warhol directory in your custom plugins:

    git clone https://github.com/unixorn/warhol.plugin.zsh.git warhol

  3. Edit your ~/.zshrc and add warhol.plugin.zsh – same as clone directory – to the list of plugins to enable:

    plugins=( ... warhol )

  4. Then, restart your terminal application to refresh context and use the plugin. Alternatively, you can source your current shell configuration:

    source ~/.zshrc

Without using any frameworks

  1. git clone git@github.com:unixorn/warhol.plugin.zsh.git
  2. Add its bin directory to your $PATH. If you're using ZSH, you can just add source /path/to/clone/of/warhol.plugin.zsh to your ~/.zshrc file.

The scripts in here don't actually require you to be using ZSH as your login shell, they're being distributed as a ZSH plugin because that's convenient.

Tips

Customizing LSCOLORS for macOS/BSD and LS_COLORS for Linux is a hassle. It's even more of a hassle to keep them in sync across macOS/BSD and Linux.

Fortunately, Geoff Greer made lscolors that makes it easy to customize your color scheme and keep it in sync across Linux and OS X/*BSD.

The easiest way to change them if you use a ZSH framework is to redeclare the variables in your .zshrc after your framework loads your plugins.

About

Colorize command output using grc and lscolors

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages