Coder Social home page Coder Social logo

OS: Ubuntu: xclip about blog HOT 3 OPEN

xvno avatar xvno commented on July 18, 2024
OS: Ubuntu: xclip

from blog.

Comments (3)

xvno avatar xvno commented on July 18, 2024

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.

xvno avatar xvno commented on July 18, 2024

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.

xvno avatar xvno commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.