Easily create new CLI aliases with `new-alias`

I love stuff like this:


It’s a handy little alias to create aliases for commands you just ran … an “alias-generating alias”; my inner geek rejoices 🙂

Here’s the code (add it to your .bash_profile):

new-alias() {
  local last_command=$(echo `history |tail -n2 |head -n1` | sed 's/[0-9]* //')
  echo alias $1="'""$last_command""'" >> ~/.bash_profile
  . ~/.bash_profile

Usage: new-alias name-for-the-alias

An alias for new aliases →


It’s showtime in a terminal near you! Put on your best colours, resize to 80 columns, and let your fingers fly!

Termshows are purely text based. This makes them ideal for demoing instructions (as the user can copy-paste), making fail-safe “live-coding” sessions (plain text is very scalable), and sharing all your l33t terminal hacks.

Great for teaching. Looks like I’ll need to replace my half-assed (and manual) attempts such as http://bramus.github.io/ws2-sws-course-materials/xx.git.html#/2/5 with this.

showterm →