Skip to content

Commit

Permalink
remove dependencies
Browse files Browse the repository at this point in the history
I wrote this method in Active Support, so this is not reinventing
the wheel, because you cannot reinvent what you invented! Pure logic!
  • Loading branch information
fxn committed Feb 9, 2018
1 parent 7949bcf commit e9eae12
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/ui
@@ -1,10 +1,13 @@
#!/usr/bin/env ruby

# This utility is helpful when you want to paste snippets of code unindented.
# For example, for blog post, Slack channel, personal wiki, etc.
# Very handy to copy code snippets from the editor to a Slack channel, slides,
# personal notes, etc.

require 'active_support/core_ext/string/strip'
text = `pbpaste`
indent = text.scan(/^[ \t]*(?=\S)/).min
text.gsub!(/^#{indent}/, '')

open('| pbcopy', 'w') do |io|
io.write(`pbpaste`.strip_heredoc)
io.write(text)
end

0 comments on commit e9eae12

Please sign in to comment.