Comments (3)
How
xclip is a commandline interface to the X selections (clipboard). This tool helps you to copy the output of any command directly into the clipboard and saves you from manually copying and pasting from the terminal. If you have tried copying from the terminal output, you have already realized how tedious the task is. Imagine, if the output is very long, it will be difficult to copy the output manually. This is where xclip tool can benefit you. You can copy the output of any command using this tool. It also allows you to copy the contents of a file directly into the clipboard as well as print the contents of a selection to the standard out.
Installing xclip
xclip is available as a package for Ubuntu so, it can be installed as below. Open a terminal Ctrl + Alt + T and run:
sudo apt-get install xclip
# Using xclip
# To copy the output of a command into the clipboard, pipe the command into xclip as below:
# Long version
ls -la | xclip -selection clipboard
# Short version
ls -la | xclip -sel clip
# This puts the output of ls -la command into the clipboard, and you can now paste the output into any other program (eg. a text editor) with Ctrl + V outside terminal and Ctrl + Shift + V inside terminal.
# To copy the contents of a file (eg. /etc/apt/sources.list) into the clipboard:
# Long version
xclip -selection clipboard -in /etc/apt/sources.list
# Short version
xclip -sel clip -i /etc/apt/sources.list
# To print the contents of the clipboard:
# Long version
xclip -selection clipboard -out
# Short version
xclip -sel clip -o
# To save the contents of the clipboard to a file (eg. ~/myfile.txt):
# Long version
xclip -selection clipboard -out > ~/myfile.txt
# Short version
xclip -sel clip -o > ~/myfile.txt
from blog.
Alias
alias xc="xclip -sel clip" # copy into clipboard
alias xcat="xclip -sel clip -i" # copy file content into clipboard, `pbcopy < filename`
alias pbcopy="xclip -sel clip -i" # As macOS does
alias xv="xclip -sel clip -o" # output from clipboard
from blog.
Usage
# copy file.txt
pbcopy file.txt
# paste
xv
# copy output from a formor command
ls -lh | xc
# paste
xv
from blog.
Related Issues (20)
- HTML: JS: meta-viewport HOT 1
- JS: snake case & camel case HOT 1
- Docker: WordPress, Nginx HOT 2
- Nuxt: [BABEL] Note: The code generator has deoptimised the styling of XXX.js as it exceeds the max of 500KB. HOT 1
- Nginx: Tips HOT 2
- Shell: Tips HOT 1
- Nacos: Tips HOT 2
- Xnix: LVM: Tips
- OS: Ubuntu: apt HOT 1
- OS: Ubuntu: user HOT 1
- OS:Ubuntu: Nvidia GPU HOT 5
- OS: Ubuntu: CUDA
- OS:Ubuntu:zshconfig
- Web: blogs
- Network: tools: curl
- PL: node.js: egg.js HOT 2
- FFMPEG: ProRes HOT 1
- Networking: 阿里云: 云解析DNS HOT 3
- Shell: scripts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.