Tech News
← Back to articles

Scripts I wrote that I use all the time

read original related products more articles

In my decade-plus of maintaining my dotfiles, I’ve written a lot of little shell scripts. Here’s a big list of my personal favorites.

Clipboard

copy and pasta are simple wrappers around system clipboard managers, like pbcopy on macOS and xclip on Linux. I use these all the time.

# High level examples run_some_command | copy pasta > file_from_my_clipboard.txt # Copy a file's contents copy < file.txt # Open a file path from your clipboard vim " $( pasta ) " # Decode some base64 from the clipboard pasta | base64 --decode

pastas prints the current state of your clipboard to stdout, and then whenever the clipboard changes, it prints the new version. I use this once a week or so.

# High level example pastas > everything_i_copied.txt # Download every link I copy to my clipboard pastas | wget -i -

cpwd copies the current directory to the clipboard. Basically pwd | copy . I often use this when I’m in a directory and I want use that directory in another terminal tab; I copy it in one tab and cd to it in another. I use this once a day or so.

File management

mkcd foo makes a directory and cd s inside. It’s basically mkdir foo && cd foo . I use this all the time—almost every time I make a directory, I want to go in there.

tempe changes to a temporary directory. It’s basically cd "$(mktemp -d)" . I use this all the time to hop into a sandbox directory. It saves me from having to manually clean up my work. A couple of common examples:

... continue reading