Skip to content

Instantly share code, notes, and snippets.

@zewebdev1337
Created October 21, 2024 20:37
Show Gist options
  • Save zewebdev1337/b042fde3ce2eb4637d0601de159c33c3 to your computer and use it in GitHub Desktop.
Save zewebdev1337/b042fde3ce2eb4637d0601de159c33c3 to your computer and use it in GitHub Desktop.

Revisions

  1. zewebdev1337 created this gist Oct 21, 2024.
    22 changes: 22 additions & 0 deletions clip
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash

    # Check if a filename is provided
    if [ -z "$1" ]; then
    echo "Usage: $0 <filename>"
    exit 1
    fi

    # Use the provided filename
    filename="$1"

    # Check if the file exists
    if [ ! -f "$filename" ]; then
    echo "File not found: $filename"
    exit 1
    fi

    # Copy the content of the file to the clipboard
    cat "$filename" | xclip -selection clipboard

    echo "Content of $filename copied to clipboard."