Skip to content

Instantly share code, notes, and snippets.

@blakek
Last active August 29, 2015 14:26
Show Gist options
  • Save blakek/9777f551d826b06178c3 to your computer and use it in GitHub Desktop.
Save blakek/9777f551d826b06178c3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
output=''
ARGV.each_with_index { |arg, index|
unless index == 0
output.concat('-')
end
output.concat(arg.downcase.gsub(/[^[:alnum:]]/,''))
}
pbcopy output
print output
print "\n"
@blakek
Copy link
Author

blakek commented Aug 7, 2015

Changes a heading (e.g. My New Gist) to something that can be an element id or class (e.g. my-new-gist). Works great when piping to pbcopy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment