Last active
July 12, 2025 10:11
-
-
Save octiwhale/6ae5cefe5631a1a4e632019599431ccf to your computer and use it in GitHub Desktop.
fcop.sh - copy file contents to clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # fcop - Copy file contents to clipboard (quiet version) | |
| FILE="$1" | |
| # Usage check | |
| [ -z "$FILE" ] && { echo "Usage: fcop <filename>"; exit 1; } | |
| # File exists? | |
| [ ! -e "$FILE" ] && { echo "'$FILE' not found."; exit 1; } | |
| # Check if readable by current user | |
| if [ -r "$FILE" ]; then | |
| cat "$FILE" | pbcopy | |
| exit 0 | |
| fi | |
| # If not readable, show file metadata | |
| INFO=$(ls -ld "$FILE") | |
| OWNER=$(stat -f '%Su' "$FILE") | |
| GROUP=$(stat -f '%Sg' "$FILE") | |
| PERMS=$(stat -f '%Sp' "$FILE") | |
| echo "No read access to '$FILE'." | |
| echo "$OWNER:$GROUP, $PERMS" | |
| # Interactively request perms | |
| sudo cat "$FILE" | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment