> Speed Up Terminal Tab/Window Load Time on OSX

Terminal uses /usr/bin/login to launch new shells, by default this prints out the last login time and the contents of /etc/motd. To look up the last login time login searches through the ASL (Apple System Log) database in /var/log/asl/. These log files can be very…

> Setup a Remote Shell over ICMP (ping)

There may be a tighter way to accomplish this, but these are the basic steps for setting up a remote shell over ICMP. remote First, on the remote system we setup some named pipes, and attach them to the STDIN and STDOUT (we also direct STDERR to STDIN) of a…

> Switching from MacPorts to Homebrew

Decided I'd give Homebrew a try - here's the process I used to switch over. Make a list of your ports for reference later: port installed > ports.txt Might be worth going through that list, clear out the dependency ports you can identify and leave a list of the…

> Find IPs Accessing your Site Most

cut -d ' ' -f 1 /var/log/httpd/access_log | sort | uniq -c | sort -n 109 192.187.110.211 119 192.187.98.162 132 192.187.114.53 139 192.187.99.202 155 221.7.132.2 List IPs that have made requests to an Apache…

> Sort Human Readable File/Directory Sizes

When using sort the -h or the longopt version --human-numeric-sort sort human readable numbers (e.g., 2K 1G) du -hd1 | sort -h 321M ./.ccache 508M ./build-perl-squeeze 862M ./7.6.1 Add -r to sort to get the largest listed first.…

> A Couple Ways to Return a Random Number on the Command Line

Lets explore a couple ways to get random numbers on the command line. Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin. John von Neumann $RANDOM Bash Internal $RANDOM is an internal Bash function (not a constant) that returns a…

> Re-call Command Line Arguments in BASH

BASH's history expansion character, ! has many features, including !: for choosing a specific argument (or range of arguments) from the history. The gist is any number after !: is the number of the argument you want, with !:1 being the first argument and !:0 being the command. echo one two three one…

> Simple Way to Get your External IP on the Command Line

This is an easy way to see what IP a website is seeing you come from: curl httpbin.org/ip { "origin": "52.11.93.181" } curl icanhazip.com 52.11.93.181 Lots of other options, but these are some of the shortest I've seen.…

> Google text-to-speech in MP3 Format via the Command Line

The function will take a string and create an MP3 of the string being spoken and named after the first 15 characters of the string: t2s() { wget -q -U Mozilla -O $(tr ' ' _ <<< "$1"| cut -b 1-15).mp3 "http://translate.google.com/translate_tts?ie=UTF-8&…

> A Couple Ways to Identify the Shell you're Using

ps -p $$ PID TTY TIME CMD 76146 ttys002 0:54.05 -bash echo $SHELL /bin/bash The first gets the PID and command of the current shell, the second is an environment variable that should be set in most shells.…