Monthly Archives: April 2016

Fix Clipboard History for Mac Crashing

Everyone needs a clipboard history app. I just don’t understand how people are able to be efficient when their clipboard can only hold one item!

For the past few years, I have used Clipboard History and while I am sure that there are newer/better options that have popped up, this has worked for me for years and I just had no reason to change. That is until tonight.logo

I apparently copied WAY too much out of Excel, multiple times, and caused Clipboard History to freak out and required me to kill the process from terminal. Every time when I restarted the app, it would immediately crash again since it was trying to load my old history. This even persisted after reboot. The app immediately crashed, not allowing me to do anything with it.

In case anyone else runs into this, I was able to restore the app by manually tracking down the history and deleting it.

Fire up terminal, and navigate to ~/Library/Application Support/com.agileroute.clipboardhistory

In this directory, there is a directory for each of your clips, each with its own ID number. Inside those directories, there is the actual clip itself, in HTML, txt, etc and a properties file. It is important to note that your “Favorite” clips that never go away are also stored in here.

To fix Clipboard History, I did “ls -alt | head” to see what the IDs were for my oldest clips. These are your “Favorites” and you likely want to save them. Once you have identified what you want to keep, move them somewhere safe, delete everything else, and then move them back. I did the following (assume that 322 and 2608 are my “Favorites”)

Close terminal, and then fire up Clipboard History again, and all should be right with the world.

Open Duplicate Chrome Tabs with Bash

As I was writing the TabIt post last week, I thought about including an option to duplicate a specific tab. It was a fleeting thought as I told myself “Nah, when would anyone ever need to open a bunch of the same tab?”.dupetab

As you would expect, literally the very next day I ran into a situation where I needed to open a bunch of duplicate tabs. In my case, we use Workday at Rackspace as our ERP. I was reviewing goals for ~100 folks, and didn’t want to go through “Click > Load Time > Click > Load Time > Read > Back > Back > Load Time” for every single one. While I’m a big fan of Workday, they have some weird javascript in their web application that prevents the normal shortcut to open a link in a new tab (CMD + Click) from working.

I decided the fastest way to do this was going to be to open a bunch of the same tab that list the employees and then use one tab per employee so I didn’t have to spend so much time waiting for Workday to load each page.

I tweaked TabIt to become DupeTab. The source is at: https://github.com/joshprewitt/tabit/blob/master/dupetab

Just like with TabIt, paste the source into a file in your path (or /usr/local/bin if you don’t know what that means), then make it executable

Once it is executable and in your path, you can call it just like any other command. If you run dupetab without any arguments, it will show the following help documentation:

Help documentation for dupetab
Basic usage: dupetab [options] <URL to replicate>
Options:
-n <count of tabs to open. Default is 5>
-s <Sleep between tabs. Default is 0.>
-c — Use Current Window.

If the URL has any special characters in it, you might want to wrap it in single quotes. The options are pretty self explanatory: -n will determine how many duplicates of the tab to open, and -c will have the tabs open in your current window instead of opening a new window just for the duplicates. With Workday, I ran into an error of too many concurrent connections, so I added in the -s option to specify a sleep time between tabs.

Here is is all together. Say you needed to open 12 tabs of http://google.com with a 2 second delay between opening each tab:

Keyboard Shortcuts

Just like with TabIt, don’t forget your keyboard shortcuts when working with a bunch of tabs

Shortcut Keys Action
Cmd+Shift+{ Go to Left Tab
Cmd+Shift+} Go to Right Tab
Cmd+w Close Tab
Cmd+Shift+T Re-Open Most Recently Closed Tab
Click a tab + Shift + Click a different tab Select Range of Tabs (Cmd+w will close all selected tabs)

Gotchas

This assumes a standard installation of Chrome. If you installed Chrome to a different location, you will need to change lines 64 and 70.

References

Artwork: New Window by Marek Polakovic from the Noun Project

TabIt – Open Tabs in Chrome with a Variable

I constantly find myself needing to open a lot of similar tabs to research something at work. For example, maybe I want to review account notes on a few dozen accounts, or I want to audit 30-40 support tickets.

Most web apps usually just pass unique identifiers in the URL itself. For example, if you use Zendesk, a ticket URL might be https://subdomain.zendesk.com/tickets/123456 where 123456 is the Ticket ID number. You might have an internal CRM tool that has a URL like https://internal.company.com/accounts/95438.browsertabs

It doesn’t take a genius to figure out that by just changing the 95438 in the URL to a different number, you pull up a different account. So instead of going through the trouble of searching in the web app, most people just change the URL to the account they are looking for, or create a custom search in their browser.

When I have more than 4 or 5 of the same type of item I want to review (Tickets, Accounts, whatever), it becomes tedious to copy each item, open a new tab manually, paste the variable, and wait for the page to load.

For cases like this, I wrote a simple bash utility that I call tabit. Tabit has one job: Read input from a file and open a bunch of tabs with the specific variables. Here is a quick example using Youtube (since I obviously won’t share the links to Rackspace’s internal tools).

Say you have a list of the 10 most popular Youtube Video IDs.

We know that Youtube’s URL format is https://www.youtube.com/watch?v=<Unique ID>. Instead of manually copying/pasting that 10 times, here is how you would do it with Tabit.

First, grab the source from github: https://github.com/joshprewitt/tabit or copy the script below.

Place it somewhere in your default path. If you don’t know what that means, just put it at /usr/local/bin/tabit

Make it executable:

By default, Tabit looks for a file in your user’s home directory called ‘.tabit’. Paste the list of Youtube IDs into that file. If you are on a Mac and just copied the list above, the following will do the trick:

All that is left to do now is run the script. Using the defaults, the syntax is really simple: Just run

I added a few options like the ability to specify a file instead of the default ~/.tabit and also the option to have the tabs open in your current Chrome window. Lastly, if you happen to have a URL where the variable is NOT the last part of the URL, you can add on a suffix. You get the following help documentation if you run tabit with no arguments:

Help documentation for tabit

Basic usage: tabit [options] <start of URL with trailing slash> [Remainder of URL with leading slash]

Options:
-f <path to file>. — File to read variables from. Default is ~/.tabit
-c — Use Current Window.

That’s it! After you get used to using this, you will find that it is much easier to just paste the variables into ~/.tabit and run the script instead of manually opening a bunch of tabs.

Keyboard Shortcuts

When working with dozens (to hundreds) of tabs, don’t forget these shortcuts

Shortcut Keys Action
Cmd+Shift+{ Go to Left Tab
Cmd+Shift+} Go to Right Tab
Cmd+w Close Tab
Cmd+Shift+T Re-Open Most Recently Closed Tab
Click a tab + Shift + Click a different tab Select Range of Tabs (Cmd+w will close all selected tabs)

Gotchas

The script assumes a standard installation of Google Chrome. If you installed it somewhere else, you will need to edit lines 58 and 62 with the correct path to Chrome on your system.

References

Optargs help came from http://tuxtweaks.com/2014/05/bash-getopts/

Picture: Browsers by Eightemdi from the Noun Project