Yes, yes, I knew about 'xclip' before now -- but it was just way too hard to use because it made me type (and remember) lots of options for simple clipboard operations.
Introducing 'xcl', a simple, helpful wrapper around 'xclip':
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# While 'xclip' is helpful, it's way too verbose, | |
# and the defaults are unhelpful for common | |
# "Ctrl-C/V" type usages. | |
# | |
# This 'xcl' utility transforms 'xclip' into a | |
# helpful cmdline friend. | |
# | |
# usage: | |
# - cat some_file | xcl | |
# - xcl > some_file | |
# | |
# read from clipboard if stdin is a tty, otherwise write to clipboard | |
[ -t 0 ] && xclip -o -selection clipboard || xclip -i -selection clipboard |
This uses a little-known trick from bash (really from the 'test' or '[' builtin), which allows me to detect whether a file descriptor is attached to a live terminal.
Hope this is helpful to you.
No comments:
Post a Comment