DEV Community

Cover image for The Ultimate Clipboard, period.
Santiago for The S Word

Posted on • Originally published at theswordblogsite.wordpress.com on

The Ultimate Clipboard, period.

It’s no secret that we, software workers, search on the bast internet sea for answers to our problems. And when we find them, we copy them, and paste them on our project. But some times we need to replicate the solution we implemented to fix an issue, to solve another issue somewhere else. And some other times, we just want to copy and past some stuff. And… some other other times, we may want to do all that at the same time.

If you’re like me, then the “regular” clipboard runs short pretty fast, and quite frequently as well. A few years ago someone recommended me to install this tool, and my life changed completely after that… at least my life from 9 to 5 from Mondays to Fridays…

Let me show your how to install and use the ultimate clipboard you’ll ever need. All aboard!

Clipy

I know, you thinking about that old pet from certain writing tool right?

Sorry, but no, is not that one (though you can have it back if you want it: here). The one I’m talking about is with a single P. Clipy is a Clipboard extension app for macOS.

Its idea is simple enough, add a history to your clipboard. Each time you press “Cmd+C”, it gets added first on the list of you clipboard history. “Cmd+V” paste what you have at the top of the clipboard history. And if you press “Cmd+Shift+V”, you get to pick what to paste from your history.

And it doesn’t stops there, this tool not only adds more room to your clipboard, but also allows you to create snippets to store your most commonly used “pastes”. You can even create “folders” to group them and have some useful code snippets, URLs, Ascii Emojies (¯_(ツ)_/¯) , or commands.

Get it

The installation is pretty straight forward.

  1. Download the binary from their distribution site: https://clipy-app.com/.
  2. Move it into your Applications folder.
  3. There is no step 3.

How I use it

It has proven to be extremely handy in many occasions to me already. On my daily work I’m used to copy a lot of commands, some to replicate on different environments, or simply to run again later. Also, copying some values to add to my code or commands, and being able to reuse that data later on is really useful as well.

Regarding the snippets, I use them to keep at hand the commands and code sample I use the most. For instance, I work with many git repos and branches, and I like keep my workspace clean, that means, removing merged and deleted branches for instances. Of course, deleting them one by one not only is boring but also time consuming. So I have this git command to delete all branches on my local that have been removed from the remote repo:

git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done
Enter fullscreen mode Exit fullscreen mode

Feel free to add it to your snippets :D. I also have a commands to create a diff report between tags, another one to calculate the cadence of a branch, and even the LOCs (yeah, still use that one sometimes).

And since I’m an automation maniac, I also keep a template for any new script I create:

#!/usr/bin/env bash
set -o errexit

set -o nounset
set -o pipefail
if [["${TRACE-0}" == "1"]]; then
    set -o xtrace
fi

main() {
    # Add Code Here
}

main "$@"
Enter fullscreen mode Exit fullscreen mode

This is the template I use to create a script with some of the best practices I like to have implemented on my scripts from the very start. Those are:

  • errexit : the script exist whenever any commands returns a non-zero code. So you don’t miss any execution errors
  • nounset : the script will fail if you try to use any environment variables that hasn’t been declared. So you don’t forget to initialize them or mistype any names.
  • pipefail : I use pipelines a lot ( i.e.: command 1 | command 2 | command3 ), by default only the exit code of the last command is returned. By enabling this option, if any of the commands fail, the script will return the error code instead. This has saved my hours of debugging time.
  • xtrace : If you run the script by adding “TRACE=1” in front of it, you’ll get a lot of extra logs to debug.
  • main function: the main login of the script encapsulated on a function.

Go For It

This is one of the very first tools I always get installed on new machines. It has proven it’s value to me, and I can’t conceive my daily work with out it nowadays.

Hope you find it as useful as I did, and feel free to copy my snippets as well 😀

Enjoy! *Sails away….

Top comments (0)