Welcome to CLI Magic!

The command line is a seriously powerful place, but it can be a bit like arcane magic trying to divine the right incantation of flags and commands.

This will be a series of short posts that give one or two commands that do something really cool or powerful in a condensed form, with a short explanation of what they do. They might be useful or just fun. The commands here will be primarily for Bash on Mac/Linux but can usually be adapted for most *nix environments.

Let’s begin with a command I used the other day. This is useful if you want to view a file kept on a remote computer using your favorite text editor on your mac (without depending on any X window nonsense)

ssh user@server.name "cat /absolute/path/to/file" | open -fa "/Applications/Example.app"

For example I opened a wordpress theme php file with sublime text to debug the website

ssh root@ourserverat.eclarian.com "cat /example/wp-content/themes/MyTheme/template-home.php" | open -fa "/Applications/Sublime Text.app"

(And no that is not the real name of our servers)