119 Labs LLC

Ideas on Technology

Pbpaste & Pbcopy

I love pbpaste and pbcopy. They are utilities on osx that allow you to write to and read from the copy buffer. They really have unlimited use in productivity scripts for transforming information. My most frequent use though is when I want to open a new tab in Terminal and stay in the same directory. In order to do this in Terminal I:
  1. type “pwd | pbcopy”
  2. Apple-T
  3. cd <paste>
This is even snazzier with a touchstream. I used to run in to the problem all the time where some one would send me a unc style path and I needed to open it up on my mac. To get around this I wrote the following script:
### unc2smb.sh ###
#!/bin/sh

pbpaste|sed -e "s,[\\][\\],smb://," -e  "s,[\\],/,g" -e "s,\(.*\)/\([^/]*\),\1/,"|pbcopy
Now just copy your unc style (\server\folder) path and run unc2smb.sh. Now when you use a standard paste, you’ll instead paste the osx friendly smb style (smb://). One last step, I added unc2smb.sh to quciksilver. Now when I get a unc style path in an email I:
  1. Select & copy the path
  2. run unc2smb.sh from the quicksilver command menu (or you could bind it to a key)
  3. Connect to server
  4. <Paste>
Still not a great process, but better than I had before. Anyways combining pbpaste, pbcopy, & sed can really give you a huge amount of control