structure updates
This commit is contained in:
93
tech_docs/linux/copy_paste.md
Normal file
93
tech_docs/linux/copy_paste.md
Normal file
@@ -0,0 +1,93 @@
|
||||
Certainly! Here’s a quick start guide for both `xclip` and `xsel` on Debian. These tools help you interact with the clipboard directly from the command line, which can be especially useful for scripting and handling text like Markdown and AsciiDoc.
|
||||
|
||||
### Getting Started with xclip
|
||||
|
||||
#### Installation
|
||||
|
||||
First, ensure `xclip` is installed on your system. Open a terminal and run:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install xclip
|
||||
```
|
||||
|
||||
#### Basic Usage
|
||||
|
||||
- **Copy Text to Clipboard:**
|
||||
|
||||
To copy text from a file to the clipboard, use:
|
||||
|
||||
```bash
|
||||
xclip -selection clipboard < file.txt
|
||||
```
|
||||
|
||||
Replace `file.txt` with the path to your file.
|
||||
|
||||
- **Copy Command Output to Clipboard:**
|
||||
|
||||
You can also pipe the output of a command directly into `xclip`:
|
||||
|
||||
```bash
|
||||
echo "Hello, World!" | xclip -selection clipboard
|
||||
```
|
||||
|
||||
- **Paste from Clipboard:**
|
||||
|
||||
To paste the clipboard content back into the terminal (e.g., to view what's been copied), use:
|
||||
|
||||
```bash
|
||||
xclip -selection clipboard -o
|
||||
```
|
||||
|
||||
#### Advanced Tips
|
||||
|
||||
- You can use `xclip` without specifying `-selection clipboard` for quick copy-paste operations within the terminal using the primary buffer (middle-click to paste).
|
||||
- `xclip` can handle various data formats, but for text manipulation in scripts, the default behavior is usually sufficient.
|
||||
|
||||
### Getting Started with xsel
|
||||
|
||||
#### Installation
|
||||
|
||||
Ensure `xsel` is installed by running:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install xsel
|
||||
```
|
||||
|
||||
#### Basic Usage
|
||||
|
||||
- **Copy Text to Clipboard:**
|
||||
|
||||
Similarly, to copy text from a file to the clipboard, use:
|
||||
|
||||
```bash
|
||||
xsel --clipboard < file.txt
|
||||
```
|
||||
|
||||
- **Copy Command Output to Clipboard:**
|
||||
|
||||
Pipe a command’s output into `xsel` to copy it to the clipboard:
|
||||
|
||||
```bash
|
||||
echo "Hello, World!" | xsel --clipboard
|
||||
```
|
||||
|
||||
- **Paste from Clipboard:**
|
||||
|
||||
To output the content of the clipboard to your terminal, use:
|
||||
|
||||
```bash
|
||||
xsel --clipboard --output
|
||||
```
|
||||
|
||||
#### Advanced Tips
|
||||
|
||||
- `xsel` is particularly straightforward and does not have as many options as `xclip`, making it easier to use for simple tasks.
|
||||
- Use `xsel` for quick clipboard operations within scripts or when working in the terminal. It excels in simplicity and ease of use.
|
||||
|
||||
### Choosing Between xclip and xsel
|
||||
|
||||
Both tools are efficient for copying and pasting text via the command line. Your choice might boil down to the specific features you need or personal preference after trying them out. For instance, you might find one’s syntax more intuitive or prefer the way one of the tools handles specific data types or clipboard operations.
|
||||
|
||||
Remember, while these tools are command-line based and work well in terminal environments, their functionality depends on the X Window System. Therefore, they are suited for use in graphical user environments where an X server is running.
|
||||
Reference in New Issue
Block a user