A simple clipboard utility for piping content to xclip.
gem install clip.rbRequires xclip to be installed on your system.
# Copy file contents to clipboard
cat file.txt | clip
# Copy and echo the content
cat file.txt | clip -e
# Copy only the first N lines
cat file.txt | clip -l 10
# Wrap content in markdown code fence
cat script.rb | clip -m ruby
# Append to existing clipboard content
cat more.txt | clip -a
# Paste clipboard contents to stdout
clip
# Grep outputs filename AND content:
grep -rn "TODO" src/
# src/app.rb:42:# TODO: refactor this
# src/app.rb:87:# TODO: add tests
# src/lib.rb:12:# TODO: fix bug
# Use -l 1 to copy just the first match (with filename)
grep -rn "TODO" src/ | clip -l 1-l,--line NUMBER- Copy only the first N lines-e,--echo- Output copied content to stdout-a,--append- Append to clipboard instead of replacing-m,--markdown [LANGUAGE]- Wrap in markdown code fence-h,--help- Print help
Bug reports and pull requests are welcome on GitHub.
After checking out the repo:
bin/setup
bundle exec rake testThe gem is available as open source under the terms of the MIT License.