To use any of these, just put them in a file and source them from your login profile (
Write a quick Markdown list
This first one is super simple. It just takes a tab-indented list from STDIN and outputs a Markdown bullet list in Terminal. It removes blank lines and maintains indentation using
You can just run qlist and type the list in Terminal, ending input with
⌃d on a blank line, or pipe input in from
pbpaste or a file.
qlistpb alias at the end is just a shortcut for piping the output to the clipboard instead of STDOUT.
qlist: quick markdown list
Quickly list IP addresses for the current machine
Next, a function to quickly list internal and WAN ip addresses. It uses
ifconfig for the local IP, and then dig with the OpenDNS resolver for the WAN address. It works just as well with icanhazip.com using
curl -sS icanhazip.com instead of the
dig command, but I have more faith in the OpenDNS method being futureproof.
Updated: Thanks to comments from Keith Rollin and Daniel Whicker the script now iterates through all available network interfaces to find one that’s active.
**Also, Kai Wells has created a fish version of
lips: list ip addresses
Convert HEX to RGB
Lastly, a function to convert hex color string to RGB using
printf. This one takes a 6-character hex code (e.g.
#faf1cb) and converts it to an RGB string, (e.g.
The leading hash (
#) is optional and will be cleared out if it exists. The hex string is case-insensitive, so
FAF1CB will work as well. If the input given is 3 characters, it will be automatically expanded, doubling each character, so
If you want to include a CSS transparency indicator in the output (RGBA), you can include a second argument that consists of a float between 0 and 1, e.g.
hex2rgb 010 .5 becomes
If you want just the numbers without the
rgb(), change the line
local css=true to
local css=. Then
hex2rgb faf1cb returns
hex2rgb: convert hex color strings to rgb
For fish users, a simplified version of this function from Kai Wells.
Ryan Irelan has produced a series of shell trick videos based on BrettTerpstra.com posts. Readers can get 10% off using the coupon code