Skip to content

Instantly share code, notes, and snippets.

@jpdevries
Last active December 18, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpdevries/5846502 to your computer and use it in GitHub Desktop.
Save jpdevries/5846502 to your computer and use it in GitHub Desktop.
Algorithm to Abbreviate file names from the center. OS X style.
filename = (numChars < maxChars) ? fileName : (fileName.substr(0,(numChars / 2) - ((numChars - maxChars) / 2)) + '...' + fileName.slice( - ((numChars / 2) - ((numChars - maxChars) / 2) - (fileExtension.length + 1))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment