xclip - clipboard copy paster config etc... xclip , xsel wl-clipboard and pbcopy etc.

 sudo apt update -y 

sudo apt upgrade -y

sudo apt install -y xclip

File to clipboard

#xclip -sel/-selection clip < Catlogue.txt

#To copy the output of a command to the clipboard:

#echo "Hello, World!" | xclip -sel clip

Pasting from clipboard

xclip -sel clip -o


Clipboard history
nano clipboard_history.sh
#!/bin/bash

# File to store clipboard history
history_file="$HOME/.clipboard_history.txt"

# Ensure history file exists
touch "$history_file"

# Function to trim history file to 1000 lines
trim_history() {
    if [ $(wc -l < "$history_file") -gt 1000 ]; then
        tail -n 1000 "$history_file" > "$history_file.tmp"
        mv "$history_file.tmp" "$history_file"
    fi
}

# Function to add current clipboard contents to history
add_to_history() {
    timestamp=$(date +"%Y-%m-%d %T")
    echo "[$timestamp] $(xclip -o -selection clipboard)" >> "$history_file"
}

# Function to display clipboard history
display_history() {
    echo "Clipboard History (last 10 entries):"
    tail -n 10 "$history_file"
}

# Main script logic
case "$1" in
    "add")
        add_to_history
        trim_history
        ;;
    "display")
        display_history
        ;;
    *)
        echo "Usage: $0 {add|display}"
        exit 1
        ;;
esac

./clipboard_history.sh add
./clipboard_history.sh display

Comments

Popular posts from this blog

SAMBA SERVER 2.0 #server

Setup SSH for accessing outside from network

Speech tools - espeak and festival etc.