How to list all services on an Ubuntu 16.04 system alvin July 23, 2017 - 1:13pm

Ubuntu FAQ: How do I list all of the services on my Ubuntu 16.04 system from the Linux command line?

Answer: Use this command:

How to copy the macOS Terminal path to the clipboard

If you want to copy the current macOS Terminal path to the clipboard, you can do it with this simple command:

$ pwd | pbcopy

pwd prints the path to STDOUT, and pbcopy reads that and copies it to the macOS clipboard. Once the path is on the clipboard you can paste it into your other applications.

Of course you can also create an alias, like this:

alias path="pwd | pbcopy"

How to copy text from the MacOS Terminal to the clipboard

If you ever need to copy text (or a text file) from the MacOS Terminal to the Mac clipboard, I can confirm that the macOS pbcopy command works. It reads from STDIN and copies the text to the clipboard, so commands like these work:

$ echo "foo bar baz" | pbcopy

$ cat /etc/passwd | pbcopy

How to jump to a screen location using a mouse click with iTerm2?

When using iTerm2, if you’re editing a file with vim and want to jump to a specific location in the file using a mouse click, just hold down the [Option] key when you do a normal left mouse click. That will take you to the location directly under the mouse cursor. (Unless the mouse cursor is beyond the end of the line. In that case the text cursor will be moved to the end of that line.)

I mention vim here because I just learned about this when using vim, but you should be able to use this with any app when using iTerm2. This is an iTerm2 feature (not a vim feature).

How to kill/disable the Dashboard in Mac OS X 10.9

OS X 10.9 is sucking the life out of my old Mac, a 2008 iMac. Like turning off everything on Star Trek’s Enterprise so you can give power to something else (like the engines or shields), I keep looking for ways to bring a little life back to it. One way I’ve read about is to kill the Dashboard on 10.9.

You can kill the Dashboard with this Mac OSX defaults command, issued in a Mac Terminal window:

Setting the Mac Terminal titlebar to the current working directory

I often work with multiple Mac Terminal tabs open, and as a result I like to set the title in the titlebar to whatever I’m working on in each tab (such as “MONGO” or “PLAY”), so I wrote a little script named settitle to let me set the title in the titlebar from the Unix command line.

More recently I realized I was often setting the title to the uppercase version of the current directory. I came up with this command pipeline (I like to call them “mashups”) to do easily do that:

How to set the Mac OS X Terminal title | Mac Terminal titlebar

I like to set the title (titlebar) on the Mac OS X Terminal application so I can tell one tab from another. For instance, I may have the Play Framework running in one tab, SBT in another, Git in another, etc. Setting the title on each Terminal tab makes my life a little easier.

To set the Terminal title, I use a script I’ve named settitle:

Emptying the Mac OS X trash from the command line

When using a Mac OS X computer, it's easy to forget that it's just Unix running under the hood ... until your iMac graphics card dies and all you can do is use single-user mode, which has no GUI ... then you're reminded very quickly that it's all just Unix.

Take emptying the trash, for instance. Graphically, you right-click the Trash Can icon, then select the Empty menu option. From the Mac command line (Terminal) you just do this:

rm -rf ~/.Trash/*

It's funny how simple that is from the command line.

How to run a Unix shell script from the Mac Finder

If you ever want to create a Unix shell script that you can give to someone else so they can double-click it and run it through the Mac OS X Finder, all you have to do is (a) name the file with the ".command" extension and (b) make it executable. So, just name your Mac/Unix script like this:


Then make it executable, like this:

chmod +x ShowProcesses.command

You can also leave out the usual #!/bin/sh part on the first line.