the evans center for sleep deprivation studies
« prev | current | next »
jun 7 2005 3:55pm
sunset on church street.
sunset on church street.

windows hack: fileclip, dirclip.

The other day I wrote these little bash functions, after realizing that I've wanted them for a long time. These are cygwin-centric; I'm not sure if they'd be useful on Linux or OSX but if so, they're easily modified.

Say you're cruising around in bash via Cygwin, and there's a file you want to open in a Windows GUI-based app. fileclip puts a file path into the clipboard so you can paste it into an open dialog, browser upload form, etc.

fileclip () {
  echo -n `cygpath -w "${PWD}/${1}"` | putclip
  echo "clipped: " `getclip`
}

Similarly, dirclip puts the current directory in the clipboard.

dirclip () {
  echo -n `cygpath -w "${PWD}"` | putclip
  echo "clipped: " `getclip`
}

Add to your .bashrc and enjoy.