by the_pwner224 · 5y ago · 0 comments
alias clip="xclip -selection clipboard"
`echo hello | clip` will copy 'hello' to the clipboard, and similarly `ls | clip` will copy a bunch of lines to the clipboard. You might need to install xclip through your package manger (the package is just named xclip on Arch). # Paste clipboard into command.
xsel --clipboard | grep foobar
# Copy into clipboard
grep foobar somefile.txt | xsel --clipboard
# Transform clipboard.
xsel --clipboard | tr A-Z a-z | xsel --clipboard
I find this so useful that I have it aliased to `c`. if [[ "$(uname)" == "Linux" ]]; then
if ! grep -q Microsoft /proc/version; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
else
alias pbcopy='clip.exe'
alias pbpaste='powershell.exe -command "Get-Clipboard"'
fi
fi